luaunit

Luaunit is a unit-testing framework for Lua, in the spirit of many others unit-testing framework. Luaunit let's you write test functions, test classes with test methods and setup/teardown functionality.

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 =
os.exit( lu.LuaUnit.run() )

本工具一更新, 其它工具很早就不再更新了:

http://lua-users.org/wiki/UnitTesting

例如

https://www.mroth.net/lunit/
----
2009
最后一版

https://github.com/Phrogz/Lunity

2012

luacoverage

LuaCov is a simple coverage analyzer for Lua scripts. When a Lua script is run with the luacov module loaded, it generates a stats file with the number of executions of each line of the script and its loaded modules. The luacov command-line script then processes this file generating a report file which allows one to visualize which code paths were not traversed, which is useful for verifying the effectiveness of a test suite.

http://keplerproject.github.io/luacov/

Instructions

Using 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 version

After cloning this repo, these commands may be useful:

  • luarocks make to install LuaCov from local sources;
  • make test to run tests (does not require installing beforehand);
  • ldoc . to regenerate documentation using LDoc. --------------------------- yummy, good tools
  • luacheck . to lint using Luacheck.--------------------------- yummy, good tools

lua UT测试工具的更多相关文章

  1. 使用 WRK 压力测试工具对 ASP.NET Core 的接口进行压力测试

    0. 简要介绍 WRK 是一款轻量且易用的 HTTP 压力测试工具,通过该工具我们可以方便地对我们所开发的 WebAPI 项目进行压力测试,并且针对测试的情况返回结果. PS:Wrk 并不能针对测试的 ...

  2. (转)MySQL自带的性能压力测试工具mysqlslap详解

    mysqlslap 是 Mysql 自带的压力测试工具,可以模拟出大量客户端同时操作数据库的情况,通过结果信息来了解数据库的性能状况 mysqlslap 的一个主要工作场景就是对数据库服务器做基准测试 ...

  3. sysbench(mysql测试工具 )

    目录 一.基准测试简介 1.什么是基准测试 2.基准测试的作用 3.基准测试的指标 4.基准测试的分类 二.sysbench 1.sysbench简介 2.sysbench安装 3.sysbench语 ...

  4. MySQL压力测试工具

    一.MySQL自带的压力测试工具--Mysqlslap mysqlslap是mysql自带的基准测试工具,该工具查询数据,语法简单,灵活容易使用.该工具可以模拟多个客户端同时并发的向服务器发出查询更新 ...

  5. 渗透测试工具BurpSuite做网站的安全测试(基础版)

    渗透测试工具BurpSuite做网站的安全测试(基础版) 版权声明:本文为博主原创文章,未经博主允许不得转载. 学习网址: https://t0data.gitbooks.io/burpsuite/c ...

  6. linux压力测试工具stress

    最近给PASS平台添加autoscaling的功能,根据服务器的负载情况autoscaling,为了测试这项功能用到了stress这个压力测试工具,这个工具相当好用了.具体安装方式就不说了.记录下这个 ...

  7. [.NET] WebApi 生成帮助文档及顺便自动创建简单的测试工具

    ==========最终的效果图========== ==========下面开始干活:生成帮助文档========== 一.创建 WebApi 项目 二.找到 HelpPageConfig.cs 并 ...

  8. RabbitMQ调试与测试工具-v1.0.1 -提供下载测试与使用

    最近几天在看RabbitMQ,所以发了两天时间写了一个调试和测试工具.方便使用. 下载地址:RabbitMQTool-V1.0.1.zip

  9. HTTP压力测试工具

    HttpTest4Net是一款基于C#实现的和HTTP压力测试工具,通过工具可以简单地对HTTP服务进行一个压力测试.虽然VS.NET也集成了压力测试项目,但由于VS自身占用的资源导致了在配置不高的P ...

随机推荐

  1. CozyRSS开发记录1-原型图与Grid

    CozyRSS开发记录1-原型图与Grid 1.使用MockPlus画出最简陋的原型图 这个界面参考了目前我最常使用的RSS阅读-傲游浏览器的内置RSS阅读器.主体框架划分为上.左下.右下三块,分别是 ...

  2. 【转】Linux下进程/程序网络带宽占用情况查看工具 -- NetHogs

    http://www.cnblogs.com/carbon3/p/5930803.html 之前VPS侦探曾经介绍过流量带宽相关的工具如:iftop.vnstat,这几个都是统计和监控网卡流量的.但是 ...

  3. python base64的加密与解密

    Base64编码是一种“防君子不防小人”的编码方式.广泛应用于MIME协议,作为电子邮件的传输编码,生成的编码可逆,后一两位可能有“=”,生成的编码都是ascii字符. 优点:速度快,ascii字符, ...

  4. 【贪心】SOJ 13983

    SOJ 13983. Milk Scheduling 这是比赛题,还是作死的我最讨厌的英文题,题目大意就是有n头奶牛,要在喂奶截止时间前给他喂奶并得到相应的含量的牛奶. 一开始的想法就是挑选截止日期的 ...

  5. jsonp模拟获取百度搜索相关词汇

    随便写了个jsonp模拟百度搜索相关词汇的小demo,帮助新手理解jsonp的用法. <!DOCTYPE html><html lang="en">< ...

  6. ffplay代码播放pcm数据

    摘抄雷兄 http://blog.csdn.net/leixiaohua1020/article/details/46890259 /** * 最简单的SDL2播放音频的例子(SDL2播放PCM) * ...

  7. YUM源设置

    1挂载光盘 先创建一个文件 /aaa 然后挂载mount /dev/cdrom /aaa 进入 /aaa   ls 查看是否挂载OK 2进入yum文件夹.将除Media以外的所有文件名改为XXXXXX ...

  8. ZeroMQ接口函数之 :zmq_tcp – 使用TCP协议的ØMQ网络单播协议

    ZeroMQ 官方地址 :http://api.zeromq.org/4-1:zmq-tcp zmq_tcp(7)          ØMQ Manual - ØMQ/4.1.0 Name zmq_t ...

  9. EF 5 最佳实践白皮书

    Performance Considerations for Entity Framework 5 By David Obando, Eric Dettinger and others Publish ...

  10. iOS-Runtime知识点整理

    本文目录 1.Runtime简介 2.Runtime相关的头文件 3.技术点和应用场景 3_1.获取属性\成员变量列表 3_2.交换方法实现 3_3.类\对象的关联对象,假属性 3_4.动态添加方法, ...