红联Linux门户
Linux帮助

Lua单元测试框架 busted

发布时间:2012-09-18 09:23:35来源:红联作者:empast
busted 是 Lua 的单元测试框架,示例代码:[code]require("busted")

describe("Busted unit testing framework", function()
describe("should be awesome", function()
it("should be easy to use", function()
assert.truthy("Yup.")
end)

it("should have lots of features", function()
-- deep check comparisons!
assert.are.same({ table = "great"}, { table = "great" })

-- or check by reference!
assert.are_not.equal({ table = "great"}, { table = "great"})

assert.true(1 == 1)
assert.falsy(nil)
assert.has.error(function() error("Wat") end, "Wat")
end)

it("should provide some shortcuts to common functions", function()
assert.are.unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }})
end)

it("should have mocks and spies for functional tests", function()
local thing = require("thing_module")
spy.spy_on(thing, "greet")
thing.greet("Hi!")

assert.spy(thing.greet).was.called()
assert.spy(thing.greet).was.called_with("Hi!")
end)
end)
end)[/code]主页:http://olivinelabs.com/busted/

下载:https://github.com/Olivine-Labs/busted

来自:开源中国社区
文章评论

共有 0 条评论