No idea why I did this…
It’s very basic currently:
You call TU:Import() which changes your environment.
After that, you can call TU:Test(args) (or just Test(args), but Script Analysis will annoy me then)
(Yeah, you could do “local Test = Test” after importing, but that’s… totally possible and ok… oh well)
The next (global) function you declare, will be linked to all Tests you have created before it.
They’re executed in order, printing nice stuff in output, etc.
Since it edits your environment, it allows me to replace your ‘error’ and ‘assert’ for nice results.
With “nice results” I mean: It prints a stacktrace… that’s about it…
Can’t do that for regular errors without writing a whole sandbox around it.
(And even with a full sandbox, the stacktrace won’t be 100% accurate)
I started writing this because I “needed” it (for like 10%, if it’s possible to give it a number) and because fun.
EDIT: Improved the horrible output format to be less horrible:
EDIT2:
TU:Test("d")
-- Does: local a = nil + 7
--> - 7. Running error: ServerScriptService.TestUnits.TestUnit.Main:24: attempt to perform arithmetic on a nil value
EDIT3: Might be useful if I actually posted the code:
https://www.irccloud.com/pastebin/FPa9MCbB/