在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
https://github.com/bluebird75/luaunit
LuaUnit supports several output formats, like JUnit or TAP, for easier integration into Continuous Integration platforms (Jenkins, Maven, ...). The integrated command-line options provide a flexible interface to select tests by name or patterns, control output format, set verbosity, ... LuaUnit works with Lua 5.1, LuaJIT 2.0, LuaJIT 2.1 beta, Lua 5.2 and Lua 5.3 . It is tested on Windows Seven, Windows Server 2012 R2 (x64), MacOs X 10.9.5 and Ubuntu 14.04 (see continuous build results on Travis-CI and AppVeyor ) and should work on all platforms supported by Lua. It has no other dependency than Lua itself. LuaUnit is packed into a single-file. To make start using it, just add the file to your project.
使用文档: http://luaunit.readthedocs.io/en/latest/#developing-luaunit
例子 local lu = require('luaunit') TestFailuresWithXml = {} --class TestFailuresWithXml.__class__ = 'TestFailuresWithXml' function TestFailuresWithXml:test_failure_with_simple_xml() lu.assertEquals( '<toto>ti"ti</toto>', 'got it' ) end function TestFailuresWithXml:test_failure_with_cdata_xml() lu.assertEquals( 'cdata does not like ]]>', 'got it' ) end function TestThatLastsALongTime() local start = os.clock() while os.clock() - start < 1.1 do end end lu.LuaUnit.verbosity = 2 os.exit( lu.LuaUnit.run() )
本工具一更新, 其它工具很早就不再更新了: http://lua-users.org/wiki/UnitTesting 例如 https://www.mroth.net/lunit/
https://github.com/Phrogz/Lunity 2012
luacoverage
http://keplerproject.github.io/luacov/
InstructionsUsing LuaCov consists of two steps: running your script to collect coverage data, and then running luacov on the collected data to generate a report. To collect coverage data, your script needs to load the luacov Lua module. This can be done from the command-line, without modifying your script, like this: lua -lluacov test.lua
or lua -erequire('luacov.runner')('myconfigfilename') test.lua
(Alternatively, you can add require("luacov") to the first line of your script.)
Once the script is run, a file called luacov.stats.out is generated. If the file already exists, statistics are added to it. This is useful, for example, for making a series of runs with different input parameters in a test suite. To start the accounting from scratch, just delete the stats file. To generate a report, just run the luacov command-line script. It expects to find a file named luacov.stats.out in the current directory, and outputs a file named luacov.report.out. This is an example output of the report file: ============================================================================== test.lua ============================================================================== 1 if 10 > 100 then *0 print("I don't think this line will execute.") else 1 print("Hello, LuaCov!") end Note that to generate this report, luacov reads the source files. Therefore, it expects to find them in the same location they were when the luacov module ran (the stats file stores the filenames, but not the sources themselves).
https://github.com/keplerproject/luacov
Using development versionAfter cloning this repo, these commands may be useful:
|
请发表评论