I have a file contain multi function and I try to write unit-test for specific function using busted framework
code.lua:
function myfunc1(a,b)
-- do someting
return c1
end
function myfunc2(a2,b2)
-- do someting
return c2
end
code_spec.lua:
describe("function test", function ()
it("test result is the same in myfunc1", function ()
local functions = require "code"
local result = functions.myfunc1(500, 200)
assert.are.same(300, result)
end)
end)
but I get error like this
code_spec.lua:4: attempt to index a boolean value (local 'functions')
I need my unit test to evaluate output for specific input in myfunc1
or myfunc2
while my code and tests are in separated files.
I test different approaches, but documentation is a little confusing or lack of good example.