【发布时间】:2022-10-20 13:33:54
【问题描述】:
我有一个包含多功能的文件,我尝试使用 busted 框架为特定功能编写单元测试
代码.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)
但我收到这样的错误
code_spec.lua:4: attempt to index a boolean value (local 'functions')
我需要我的单元测试来评估myfunc1 或myfunc2 中特定输入的输出,而我的代码和测试位于单独的文件中。
我测试了不同的方法,但文档有点混乱或缺乏好的例子。
【问题讨论】:
标签: unit-testing lua lua-busted