busted- Lua单元测试框架

网友投稿 1042 2022-10-19

busted- Lua单元测试框架

busted- Lua单元测试框架

busted 是 Lua 的单元测试框架,示例代码

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)

执行结果:

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:JVM调优-GC基本原理和调优关键分析
下一篇:(CROC 2016 - Elimination Round (Rated Unofficial Edition))A. Amity Assessment(贪心)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~