I am building a test suite for my Lua application with Busted. I am organizing tests into different files that I would like to run in a given sequence, e.g. low-level unit tests first, up to integration tests on higher-level functions. I have way too many tests to fit in a single file.
I tried to create a "master" file that is called either via the Lua interpreter or via the Busted CLI, that calls individual test files, but I can't get it to work. E.g. I'd have run_tests.lua:
require "busted.runner"()
dofile("test1.lua")
dofile("test2.lua")
dofile("test3.lua")
-- [...]
I also want to use this file to put common scaffolding functions and switching env vars, etc. to change configurations between tests.
And then, each test[n].lua would be a regular Busted file:
describe("Module 1 test", function ()
it("should do something sensical", function()
-- [...]
end)
end)
With this setup, however, the Lua interpreter cannot understand the keyword describe, even though I am requiring the Busted module in the master file.
Edit: as noted in my comment, this may be related to the busted module being local. I also tried assigning it a global variable, as in b = require "busted.runner"; b() but this still doesn't work. I am not clear on how Lua scoping should work here.
If i put the require "busted.runner"() line in the test files, only the first test runs and then exits the program (I guess that is what Busted does).
Can anyone suggest a working setup for this scenario?
loadthat should be related todofile, PIL says that "it does not compile with lexical scoping". Hencedescribebeing nil.