【问题标题】:How to implement setUp and tearDown functions in Lua before and after testcase测试用例前后如何在Lua中实现setUp和tearDown函数
【发布时间】:2014-01-18 00:01:17
【问题描述】:

我正在尝试用 lua 编写测试用例。我想在执行测试用例之前进行一些设置,并在执行测试用例之后进行拆解。我将如何在 LUA 中实现。 lua 支持吗?

myFirstLuaTesting.lua

function setUp() #Should be executed first
    --setup the testcase

function testSample1() #Should be executed after setup
    --execute assertions in test case
function testSample1() #Should be executed after setup
    --execute assertions in test case

function tearDown() #Should be executed last after testcases executed
    --tearDown the testcase

我正在使用 lunatest 框架来运行测试用例

lunatest.suite("myFirstLuaTesting")
lunatest.run()

【问题讨论】:

标签: unit-testing testing lua automation


【解决方案1】:

是的,使用名为“setup”、“teardown”、“suite_setup”和“suite_teardown”的函数。测试驱动程序不会找到您拥有的那些(setUp 和 tearDown)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-14
    • 2018-02-09
    • 2013-01-05
    • 2013-01-25
    • 2011-05-24
    • 2012-12-06
    相关资源
    最近更新 更多