• 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
  • 相关阅读:
    stutas2配置action
    Struts2 第一个入门小案例
    spring与mybati整合方法
    spring事务隔离级别以及脏读 不可重复读 幻影读
    socket编程基础
    ajax随笔
    多线程基础
    Mybatis中collection与association的区别
    Guideline 2.3.1
    苹果手机 apple pay 一不小心支付购买了自己不要的服务
  • 原文地址:https://www.cnblogs.com/lightsong/p/6240741.html
Copyright © 2020-2023  润新知