busted
busted copied to clipboard
Tests in multiple files?
How do I run them with the standalone?
I try require'busted.runner'()
in each but it only tests the first file that has it.
Good question. I am having this issue too. So far as I can tell, busted.runner uses the exit function from busted.compatibility. At the end of that exit function is a call to os.exit. This forces any use of busted.runner to exit the running lua process.

I tried sidestepping that like this:
This at least prevented the os.exit call from terminating lua. So my second test gets run, but now there's this error:
So the busted functions aren't in scope anymore for whatever reason. Going to keep working on this though.
Got it to run multiple tests using busted.runner. I changed busted.compatibility as above:
Then made a global function to clear the loaded packages of busted between tests:
This approach is probably not optimal, but it worked.
Found an issue with the above approach. All the tests are run twice. Running twice without truly clearing all the variables may cause failures the second time.
Good to know. I hope a more prominent solution will become available in the future.
While using this approach to run multiple tests in standalone mode, the flow of execution was not what I expected. Code is executed from outwards in. Hopefully these pics explain:
When run:
Also when using the method above, the outermost scope will be run twice fwiw.