busted icon indicating copy to clipboard operation
busted copied to clipboard

Tests in multiple files?

Open KayleMaster opened this issue 6 years ago • 5 comments

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.

KayleMaster avatar Apr 16 '18 08:04 KayleMaster

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.

image

I tried sidestepping that like this: image

This at least prevented the os.exit call from terminating lua. So my second test gets run, but now there's this error: image So the busted functions aren't in scope anymore for whatever reason. Going to keep working on this though.

EricFedrowisch avatar Jan 03 '20 22:01 EricFedrowisch

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: image

This approach is probably not optimal, but it worked. image

EricFedrowisch avatar Jan 03 '20 23:01 EricFedrowisch

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.

EricFedrowisch avatar Jan 06 '20 22:01 EricFedrowisch

Good to know. I hope a more prominent solution will become available in the future.

KayleMaster avatar Jan 07 '20 16:01 KayleMaster

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: image When run: image

Also when using the method above, the outermost scope will be run twice fwiw.

EricFedrowisch avatar Jan 07 '20 17:01 EricFedrowisch