zoukankan      html  css  js  c++  java
  • lua UT测试工具

    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 = 2
    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
  • 相关阅读:
    shell 自动map和unmap 应用实例url域名【升级版】
    shell 自动map和unmap 应用实例url域名【初级版】
    cloudfoundry容器实例内部测试redis连通性
    Tsunami 跨机房大数据迁移【ubuntu】
    BOS项目05——Action层抽取重复代码(接受page,rows参数,封装到pageUtils对象中;对象转Json),批量添加数据的流程,批量删除流程(主要看前端部分),easyUI选项框(发送ajax请求从region中获取数据),JsonLib转码的原理(get方法),分页查询重复调用问题
    idea与Pycharm破解(Maven+Ubuntu:http://www.cnblogs.com/LexMoon/p/JavaMavenUbuntu.html)
    BOS项目
    前端——EasyUI基本使用
    Mavent——学Java不会Maven,怎么行archetypeCatalog=internal
    SpringMVC——高级参数绑定(数组、集合),@RequestMapper 的使用,Controller方法的三种返回值类型,异常处理器,上传图片,JSON数据交互,配置拦截器
  • 原文地址:https://www.cnblogs.com/lightsong/p/6240741.html
Copyright © 2011-2022 走看看