├── test ├── ref │ ├── exampleNilDefault.txt │ ├── errFailPassNilDefault.txt │ ├── errFailPassNilDefault-failures.txt │ ├── errFailPassNilDefault-success.txt │ ├── errFailPassTextQuiet-success.txt │ ├── errFailPassTextStopOnError-1.txt │ ├── errFailPassTextDefault-success.txt │ ├── errFailPassTextVerbose-success.txt │ ├── errFailPassTapDefault-success.txt │ ├── errFailPassTapQuiet-success.txt │ ├── errFailPassTapVerbose-success.txt │ ├── errFailPassXmlQuiet-success.txt │ ├── errFailPassXmlDefault-success.txt │ ├── errFailPassXmlVerbose-success.txt │ ├── errFailPassTextStopOnError-3.txt │ ├── errFailPassTextStopOnError-4.txt │ ├── testWithXmlQuiet.txt │ ├── testWithXmlDefault.txt │ ├── testWithXmlVerbose.txt │ ├── errFailPassTapQuiet-failures.txt │ ├── exampleTapQuiet.txt │ ├── errFailPassTapQuiet.txt │ ├── errPassFailTapQuiet.txt │ ├── errFailPassTextStopOnError-2.txt │ ├── errFailPassTapDefault-failures.txt │ ├── errFailPassXmlQuiet-success.xml │ ├── errFailPassXmlDefault-success.xml │ ├── errFailPassXmlVerbose-success.xml │ ├── errFailPassXmlDefault-failures.txt │ ├── errFailPassXmlQuiet-failures.txt │ ├── errFailPassXmlVerbose-failures.txt │ ├── errFailPassTextDefault-failures.txt │ ├── errFailPassTextQuiet-failures.txt │ ├── exampleTapDefault.txt │ ├── testWithXmlDefault.xml │ ├── testWithXmlQuiet.xml │ ├── testWithXmlVerbose.xml │ ├── errFailPassTapVerbose-failures.txt │ ├── errFailPassTapDefault.txt │ ├── exampleXmlQuiet.txt │ ├── exampleXmlDefault.txt │ ├── exampleXmlVerbose.txt │ ├── errFailPassXmlDefault.txt │ ├── errFailPassXmlQuiet.txt │ ├── errFailPassXmlVerbose.txt │ ├── errFailPassTextVerbose-failures.txt │ ├── errFailPassTextDefault.txt │ ├── errFailPassTextQuiet.txt │ ├── errFailPassTapVerbose.txt │ ├── exampleTextDefault.txt │ ├── exampleTextQuiet.txt │ ├── exampleTapVerbose.txt │ ├── errFailPassXmlDefault-failures.xml │ ├── errFailPassXmlQuiet-failures.xml │ ├── errFailPassXmlVerbose-failures.xml │ ├── errFailPassTextVerbose.txt │ ├── exampleTextVerbose.txt │ ├── errFailPassXmlQuiet.xml │ ├── errFailPassXmlDefault.xml │ ├── errFailPassXmlVerbose.xml │ ├── exampleXmlQuiet.xml │ ├── exampleXmlDefault.xml │ └── exampleXmlVerbose.xml ├── test_with_xml.lua ├── test_with_err_fail_pass.lua ├── legacy_example_with_luaunit.lua ├── some_lists_comparisons.lua └── compat_luaunit_v2x.lua ├── .travis ├── setenv_lua.sh ├── platform.sh └── setup_lua.sh ├── run_unit_tests.lua ├── junitxml ├── Makefile ├── example-apache-ant.xml ├── example-jenkins.xml ├── notes-junit-compatibility.txt ├── example-bamboo-2.xml ├── junit-jenkins.xsd ├── example-bamboo-1.xml ├── junit-apache-ant.xsd └── XMLJUnitResultFormatter.java.txt ├── .appveyor ├── install-luajit.cmd └── install-lua.cmd ├── .luacheckrc ├── appveyor.yml ├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── luaunit-3.2.1-1.rockspec ├── doc ├── test_something.lua ├── Makefile ├── make.bat └── conf.py ├── example_with_luaunit.lua ├── doit.py ├── TODO.txt └── README.md /test/ref/exampleNilDefault.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/ref/errFailPassNilDefault.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/ref/errFailPassNilDefault-failures.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/ref/errFailPassNilDefault-success.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextQuiet-success.txt: -------------------------------------------------------------------------------- 1 | ..... 2 | Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected 3 | OK 4 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextStopOnError-1.txt: -------------------------------------------------------------------------------- 1 | ..... 2 | Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected 3 | OK 4 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextDefault-success.txt: -------------------------------------------------------------------------------- 1 | ..... 2 | Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected 3 | OK 4 | -------------------------------------------------------------------------------- /.travis/setenv_lua.sh: -------------------------------------------------------------------------------- 1 | export PATH=${PATH}:$HOME/.lua:$HOME/.local/bin:${TRAVIS_BUILD_DIR}/install/luarocks/bin 2 | bash .travis/setup_lua.sh 3 | eval `$HOME/.lua/luarocks path` 4 | -------------------------------------------------------------------------------- /run_unit_tests.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | require('test.test_luaunit') 4 | local lu = require('luaunit') 5 | 6 | lu.LuaUnit.verbosity = 2 7 | os.exit( lu.LuaUnit.run() ) 8 | -------------------------------------------------------------------------------- /.travis/platform.sh: -------------------------------------------------------------------------------- 1 | if [ -z "${PLATFORM:-}" ]; then 2 | PLATFORM=$TRAVIS_OS_NAME; 3 | fi 4 | 5 | if [ "$PLATFORM" == "osx" ]; then 6 | PLATFORM="macosx"; 7 | fi 8 | 9 | if [ -z "$PLATFORM" ]; then 10 | if [ "$(uname)" == "Linux" ]; then 11 | PLATFORM="linux"; 12 | else 13 | PLATFORM="macosx"; 14 | fi; 15 | fi 16 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextVerbose-success.txt: -------------------------------------------------------------------------------- 1 | Started on 03/22/16 21:29:18 2 | TestAnotherThing.test1_Success1 ... Ok 3 | TestAnotherThing.test1_Success2 ... Ok 4 | TestSomething.test1_Success1 ... Ok 5 | TestSomething.test1_Success2 ... Ok 6 | testFuncSuccess1 ... Ok 7 | ========================================================= 8 | Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected 9 | OK 10 | -------------------------------------------------------------------------------- /test/ref/errFailPassTapDefault-success.txt: -------------------------------------------------------------------------------- 1 | 1..5 2 | # Started on 03/22/16 21:58:32 3 | # Starting class: TestAnotherThing 4 | ok 1 TestAnotherThing.test1_Success1 5 | ok 2 TestAnotherThing.test1_Success2 6 | # Starting class: TestSomething 7 | ok 3 TestSomething.test1_Success1 8 | ok 4 TestSomething.test1_Success2 9 | ok 5 testFuncSuccess1 10 | # Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected 11 | -------------------------------------------------------------------------------- /test/ref/errFailPassTapQuiet-success.txt: -------------------------------------------------------------------------------- 1 | 1..5 2 | # Started on 03/22/16 21:58:32 3 | # Starting class: TestAnotherThing 4 | ok 1 TestAnotherThing.test1_Success1 5 | ok 2 TestAnotherThing.test1_Success2 6 | # Starting class: TestSomething 7 | ok 3 TestSomething.test1_Success1 8 | ok 4 TestSomething.test1_Success2 9 | ok 5 testFuncSuccess1 10 | # Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected 11 | -------------------------------------------------------------------------------- /test/ref/errFailPassTapVerbose-success.txt: -------------------------------------------------------------------------------- 1 | 1..5 2 | # Started on 03/22/16 21:58:32 3 | # Starting class: TestAnotherThing 4 | ok 1 TestAnotherThing.test1_Success1 5 | ok 2 TestAnotherThing.test1_Success2 6 | # Starting class: TestSomething 7 | ok 3 TestSomething.test1_Success1 8 | ok 4 TestSomething.test1_Success2 9 | ok 5 testFuncSuccess1 10 | # Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected 11 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlQuiet-success.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/errFailPassXmlQuiet-success.xml 2 | # Started on 03/22/16 21:29:18 3 | # Starting class: TestAnotherThing 4 | # Starting test: TestAnotherThing.test1_Success1 5 | # Starting test: TestAnotherThing.test1_Success2 6 | # Starting class: TestSomething 7 | # Starting test: TestSomething.test1_Success1 8 | # Starting test: TestSomething.test1_Success2 9 | # Starting test: testFuncSuccess1 10 | # Ran 5 tests in 0.001 seconds, 5 successes, 0 failures, 10 non-selected 11 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlDefault-success.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/errFailPassXmlDefault-success.xml 2 | # Started on 03/22/16 21:29:18 3 | # Starting class: TestAnotherThing 4 | # Starting test: TestAnotherThing.test1_Success1 5 | # Starting test: TestAnotherThing.test1_Success2 6 | # Starting class: TestSomething 7 | # Starting test: TestSomething.test1_Success1 8 | # Starting test: TestSomething.test1_Success2 9 | # Starting test: testFuncSuccess1 10 | # Ran 5 tests in 0.001 seconds, 5 successes, 0 failures, 10 non-selected 11 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlVerbose-success.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/errFailPassXmlVerbose-success.xml 2 | # Started on 03/22/16 21:29:18 3 | # Starting class: TestAnotherThing 4 | # Starting test: TestAnotherThing.test1_Success1 5 | # Starting test: TestAnotherThing.test1_Success2 6 | # Starting class: TestSomething 7 | # Starting test: TestSomething.test1_Success1 8 | # Starting test: TestSomething.test1_Success2 9 | # Starting test: testFuncSuccess1 10 | # Ran 5 tests in 0.001 seconds, 5 successes, 0 failures, 10 non-selected 11 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextStopOnError-3.txt: -------------------------------------------------------------------------------- 1 | ..E 2 | ERROR during LuaUnit test execution: 3 | test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 4 | 5 | Failed tests: 6 | ------------- 7 | 1) TestAnotherThing.test2_Err1 8 | test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 9 | stack traceback: 10 | [C]: in function 'xpcall' 11 | 12 | Ran 3 tests in 0.000 seconds, 2 successes, 1 error, 9 non-selected 13 | LuaUnit ABORTED (as requested by --error or --failure option) 14 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextStopOnError-4.txt: -------------------------------------------------------------------------------- 1 | ..F 2 | Failure during LuaUnit test execution: 3 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 4 | 5 | Failed tests: 6 | ------------- 7 | 1) TestSomething.test2_Fail1 8 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 9 | stack traceback: 10 | test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 11 | 12 | Ran 3 tests in 0.000 seconds, 2 successes, 1 failure, 9 non-selected 13 | LuaUnit ABORTED (as requested by --error or --failure option) 14 | -------------------------------------------------------------------------------- /test/ref/testWithXmlQuiet.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/testWithXmlQuiet.xml 2 | # Started on 01/01/16 22:13:04 3 | # Starting class: TestFailuresWithXml 4 | # Starting test: TestFailuresWithXml.test_failure_with_cdata_xml 5 | # Failure: test/test_with_xml.lua:13: expected: "got it" 6 | actual: "cdata does not like ]]>" 7 | # Starting test: TestFailuresWithXml.test_failure_with_simple_xml 8 | # Failure: test/test_with_xml.lua:9: expected: "got it" 9 | actual: 'ti"ti' 10 | # Starting test: TestThatLastsALongTime 11 | # Ran 3 tests in 1.102 seconds, 1 success, 2 failures 12 | -------------------------------------------------------------------------------- /test/ref/testWithXmlDefault.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/testWithXmlDefault.xml 2 | # Started on 01/01/16 22:13:02 3 | # Starting class: TestFailuresWithXml 4 | # Starting test: TestFailuresWithXml.test_failure_with_cdata_xml 5 | # Failure: test/test_with_xml.lua:13: expected: "got it" 6 | actual: "cdata does not like ]]>" 7 | # Starting test: TestFailuresWithXml.test_failure_with_simple_xml 8 | # Failure: test/test_with_xml.lua:9: expected: "got it" 9 | actual: 'ti"ti' 10 | # Starting test: TestThatLastsALongTime 11 | # Ran 3 tests in 1.101 seconds, 1 success, 2 failures 12 | -------------------------------------------------------------------------------- /test/ref/testWithXmlVerbose.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/testWithXmlVerbose.xml 2 | # Started on 01/01/16 22:13:03 3 | # Starting class: TestFailuresWithXml 4 | # Starting test: TestFailuresWithXml.test_failure_with_cdata_xml 5 | # Failure: test/test_with_xml.lua:13: expected: "got it" 6 | actual: "cdata does not like ]]>" 7 | # Starting test: TestFailuresWithXml.test_failure_with_simple_xml 8 | # Failure: test/test_with_xml.lua:9: expected: "got it" 9 | actual: 'ti"ti' 10 | # Starting test: TestThatLastsALongTime 11 | # Ran 3 tests in 1.102 seconds, 1 success, 2 failures 12 | -------------------------------------------------------------------------------- /junitxml/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # junitxml/Makefile 3 | # 4 | 5 | XMLLINT ?= xmllint 6 | TEST_APACHE = --noout --schema junit-apache-ant.xsd 7 | TEST_JENKINS = --noout --schema junit-jenkins.xsd 8 | 9 | validate-examples: validate-apache validate-jenkins 10 | 11 | # This example file is the only one that satisfies the Apache schema 12 | validate-apache: example-apache-ant.xml 13 | $(XMLLINT) $(TEST_APACHE) $< 14 | 15 | # The Jenkins schema is more relaxed, and should apply to all .xml files 16 | validate-jenkins: $(wildcard *.xml) 17 | for file in $^; do $(XMLLINT) $(TEST_JENKINS) $$file || exit 1; done 18 | -------------------------------------------------------------------------------- /test/ref/errFailPassTapQuiet-failures.txt: -------------------------------------------------------------------------------- 1 | 1..10 2 | # Started on 03/22/16 21:58:32 3 | # Starting class: TestAnotherThing 4 | ok 1 TestAnotherThing.test1_Success1 5 | ok 2 TestAnotherThing.test1_Success2 6 | not ok 3 TestAnotherThing.test3_Fail1 7 | not ok 4 TestAnotherThing.test3_Fail2 8 | # Starting class: TestSomething 9 | ok 5 TestSomething.test1_Success1 10 | ok 6 TestSomething.test1_Success2 11 | not ok 7 TestSomething.test2_Fail1 12 | not ok 8 TestSomething.test2_Fail2 13 | not ok 9 testFuncFail1 14 | ok 10 testFuncSuccess1 15 | # Ran 10 tests in 0.002 seconds, 5 successes, 5 failures, 5 non-selected 16 | -------------------------------------------------------------------------------- /test/test_with_xml.lua: -------------------------------------------------------------------------------- 1 | 2 | local lu = require('luaunit') 3 | 4 | TestFailuresWithXml = {} --class 5 | 6 | TestFailuresWithXml.__class__ = 'TestFailuresWithXml' 7 | 8 | function TestFailuresWithXml:test_failure_with_simple_xml() 9 | lu.assertEquals( 'ti"ti', 'got it' ) 10 | end 11 | 12 | function TestFailuresWithXml:test_failure_with_cdata_xml() 13 | lu.assertEquals( 'cdata does not like ]]>', 'got it' ) 14 | end 15 | 16 | function TestThatLastsALongTime() 17 | local start = os.clock() 18 | while os.clock() - start < 1.1 do 19 | end 20 | end 21 | 22 | lu.LuaUnit.verbosity = 2 23 | os.exit( lu.LuaUnit.run() ) 24 | -------------------------------------------------------------------------------- /test/ref/exampleTapQuiet.txt: -------------------------------------------------------------------------------- 1 | 1..15 2 | # Started on 01/30/16 22:19:36 3 | # Starting class: TestTiti 4 | not ok 1 TestTiti.test1_withFailure 5 | not ok 2 TestTiti.test2_withFailure 6 | ok 3 TestTiti.test3 7 | # Starting class: TestToto 8 | not ok 4 TestToto.test1_withFailure 9 | not ok 5 TestToto.test2_withFailure 10 | ok 6 TestToto.test3 11 | not ok 7 TestToto.test4 12 | not ok 8 TestToto.test5 13 | not ok 9 TestToto.test6 14 | not ok 10 TestToto.test7 15 | not ok 11 TestToto.test8a 16 | not ok 12 TestToto.test8b 17 | not ok 13 test1_withFailure 18 | not ok 14 test2_withFailure 19 | ok 15 test3 20 | # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors 21 | -------------------------------------------------------------------------------- /.appveyor/install-luajit.cmd: -------------------------------------------------------------------------------- 1 | REM Do a minimalistic build of LuaJIT using the MinGW compiler 2 | 3 | set PATH=C:\MinGW\bin;%PATH% 4 | 5 | set targetdir=%2 6 | 7 | REM retrieve and unpack source 8 | curl -fLsS -o %1.zip http://luajit.org/download/%1.zip 9 | unzip -q %1 10 | 11 | REM tweak Makefile for a static LuaJIT build (Windows defaults to "dynamic" otherwise) 12 | sed -i "s/BUILDMODE=.*mixed/BUILDMODE=static/" %1\src\Makefile 13 | 14 | mingw32-make TARGET_SYS=Windows -C %1\src 15 | 16 | REM copy luajit.exe to project dir 17 | mkdir %APPVEYOR_BUILD_FOLDER%\%targetdir% 18 | copy %1\src\luajit.exe %APPVEYOR_BUILD_FOLDER%\%targetdir%\ 19 | 20 | REM clean up (remove source folders and archive) 21 | rm -rf %1/* 22 | rm -f %1.zip 23 | -------------------------------------------------------------------------------- /test/ref/errFailPassTapQuiet.txt: -------------------------------------------------------------------------------- 1 | 1..15 2 | # Started on 03/22/16 21:58:32 3 | # Starting class: TestAnotherThing 4 | ok 1 TestAnotherThing.test1_Success1 5 | ok 2 TestAnotherThing.test1_Success2 6 | not ok 3 TestAnotherThing.test2_Err1 7 | not ok 4 TestAnotherThing.test2_Err2 8 | not ok 5 TestAnotherThing.test3_Fail1 9 | not ok 6 TestAnotherThing.test3_Fail2 10 | # Starting class: TestSomething 11 | ok 7 TestSomething.test1_Success1 12 | ok 8 TestSomething.test1_Success2 13 | not ok 9 TestSomething.test2_Fail1 14 | not ok 10 TestSomething.test2_Fail2 15 | not ok 11 TestSomething.test3_Err1 16 | not ok 12 TestSomething.test3_Err2 17 | not ok 13 testFuncErr1 18 | not ok 14 testFuncFail1 19 | ok 15 testFuncSuccess1 20 | # Ran 15 tests in 0.002 seconds, 5 successes, 5 failures, 5 errors 21 | -------------------------------------------------------------------------------- /test/ref/errPassFailTapQuiet.txt: -------------------------------------------------------------------------------- 1 | 1..15 2 | # Started on 03/22/16 21:54:40 3 | # Starting class: TestAnotherThing 4 | ok 1 TestAnotherThing.test1_Success1 5 | ok 2 TestAnotherThing.test1_Success2 6 | not ok 3 TestAnotherThing.test2_Err1 7 | not ok 4 TestAnotherThing.test2_Err2 8 | not ok 5 TestAnotherThing.test3_Fail1 9 | not ok 6 TestAnotherThing.test3_Fail2 10 | # Starting class: TestSomething 11 | ok 7 TestSomething.test1_Success1 12 | ok 8 TestSomething.test1_Success2 13 | not ok 9 TestSomething.test2_Fail1 14 | not ok 10 TestSomething.test2_Fail2 15 | not ok 11 TestSomething.test3_Err1 16 | not ok 12 TestSomething.test3_Err2 17 | not ok 13 testFuncErr1 18 | not ok 14 testFuncFail1 19 | ok 15 testFuncSuccess1 20 | # Ran 15 tests in 0.000 seconds, 5 successes, 5 failures, 5 errors 21 | -------------------------------------------------------------------------------- /.luacheckrc: -------------------------------------------------------------------------------- 1 | --[[ 2 | Luacheck configuration 3 | (see http://luacheck.readthedocs.io/en/stable/config.html) 4 | Thanks to Peter Melnichenko for providing an example file for LuaUnit. 5 | ]] 6 | 7 | only = {"1"} -- limit checks to the use of global variables 8 | std = "max" 9 | self = false 10 | ignore = {"[Tt]est[%w_]+"} 11 | 12 | files = { 13 | ["luaunit.lua"] = { 14 | globals = {"EXPORT_ASSERT_TO_GLOBALS", "LuaUnit"}, 15 | }, 16 | ["test/compat_luaunit_v2x.lua"] = { 17 | ignore = {"EXPORT_ASSERT_TO_GLOBALS", "assert[%w_]+", "v", "y"} 18 | }, 19 | ["test/legacy_example_with_luaunit.lua"] = { 20 | ignore = {"LuaUnit", "EXPORT_ASSERT_TO_GLOBALS", 21 | "assertEquals", "assertNotEquals", "assertTrue", "assertFalse"} 22 | }, 23 | ["test/test_luaunit.lua"] = { 24 | ignore = {"TestMock", "TestLuaUnit%a+", "MyTest%w+", "v", "y" } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextStopOnError-2.txt: -------------------------------------------------------------------------------- 1 | ..FFE 2 | ERROR during LuaUnit test execution: 3 | test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 4 | 5 | Failed tests: 6 | ------------- 7 | 1) TestSomething.test2_Fail1 8 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 9 | stack traceback: 10 | test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 11 | 12 | 2) TestSomething.test2_Fail2 13 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 14 | stack traceback: 15 | test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 16 | 17 | 3) TestSomething.test3_Err1 18 | test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 19 | stack traceback: 20 | [C]: in function 'xpcall' 21 | 22 | Ran 5 tests in 0.000 seconds, 2 successes, 2 failures, 1 error, 9 non-selected 23 | LuaUnit ABORTED (as requested by --error or --failure option) 24 | -------------------------------------------------------------------------------- /test/ref/errFailPassTapDefault-failures.txt: -------------------------------------------------------------------------------- 1 | 1..10 2 | # Started on 03/22/16 21:58:32 3 | # Starting class: TestAnotherThing 4 | ok 1 TestAnotherThing.test1_Success1 5 | ok 2 TestAnotherThing.test1_Success2 6 | not ok 3 TestAnotherThing.test3_Fail1 7 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 8 | not ok 4 TestAnotherThing.test3_Fail2 9 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 10 | # Starting class: TestSomething 11 | ok 5 TestSomething.test1_Success1 12 | ok 6 TestSomething.test1_Success2 13 | not ok 7 TestSomething.test2_Fail1 14 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 15 | not ok 8 TestSomething.test2_Fail2 16 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 17 | not ok 9 testFuncFail1 18 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 19 | ok 10 testFuncSuccess1 20 | # Ran 10 tests in 0.000 seconds, 5 successes, 5 failures, 5 non-selected 21 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | os: MinGW 2 | shallow_clone: true 3 | 4 | # create a build matrix to use various Lua and LuaJIT versions 5 | environment: 6 | matrix: 7 | - LUAENV: lua51 8 | - LUAENV: lua52 9 | - LUAENV: lua53 10 | - LUAENV: luajit20 11 | - LUAENV: luajit21 12 | - LUAENV: cinst 13 | 14 | # cinst occasionally has problems, allow it to fail 15 | matrix: 16 | allow_failures: 17 | - LUAENV: cinst 18 | 19 | # install required binaries via batch file (also sets %LUA% path) 20 | install: 21 | - cmd: .appveyor\install-lua.cmd 22 | 23 | cache: 24 | - lua51 -> .appveyor\install-lua.cmd 25 | - lua52 -> .appveyor\install-lua.cmd 26 | - lua53 -> .appveyor\install-lua.cmd 27 | - luajit20 -> .appveyor\install-lua.cmd 28 | - luajit21 -> .appveyor\install-lua.cmd 29 | - 'C:\Program Files (x86)\Lua -> .appveyor\install-lua.cmd' 30 | 31 | build: off 32 | 33 | test_script: 34 | - cmd: >- 35 | %LUA% -v run_unit_tests.lua --random 36 | 37 | %LUA% run_functional_tests.lua 38 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlQuiet-success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlDefault-success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlVerbose-success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlDefault-failures.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/errFailPassXmlDefault-failures.xml 2 | # Started on 03/22/16 21:29:18 3 | # Starting class: TestAnotherThing 4 | # Starting test: TestAnotherThing.test1_Success1 5 | # Starting test: TestAnotherThing.test1_Success2 6 | # Starting test: TestAnotherThing.test3_Fail1 7 | # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 8 | # Starting test: TestAnotherThing.test3_Fail2 9 | # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 10 | # Starting class: TestSomething 11 | # Starting test: TestSomething.test1_Success1 12 | # Starting test: TestSomething.test1_Success2 13 | # Starting test: TestSomething.test2_Fail1 14 | # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 15 | # Starting test: TestSomething.test2_Fail2 16 | # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 17 | # Starting test: testFuncFail1 18 | # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 19 | # Starting test: testFuncSuccess1 20 | # Ran 10 tests in 0.003 seconds, 5 successes, 5 failures, 5 non-selected 21 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlQuiet-failures.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/errFailPassXmlQuiet-failures.xml 2 | # Started on 03/22/16 21:29:18 3 | # Starting class: TestAnotherThing 4 | # Starting test: TestAnotherThing.test1_Success1 5 | # Starting test: TestAnotherThing.test1_Success2 6 | # Starting test: TestAnotherThing.test3_Fail1 7 | # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 8 | # Starting test: TestAnotherThing.test3_Fail2 9 | # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 10 | # Starting class: TestSomething 11 | # Starting test: TestSomething.test1_Success1 12 | # Starting test: TestSomething.test1_Success2 13 | # Starting test: TestSomething.test2_Fail1 14 | # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 15 | # Starting test: TestSomething.test2_Fail2 16 | # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 17 | # Starting test: testFuncFail1 18 | # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 19 | # Starting test: testFuncSuccess1 20 | # Ran 10 tests in 0.002 seconds, 5 successes, 5 failures, 5 non-selected 21 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlVerbose-failures.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/errFailPassXmlVerbose-failures.xml 2 | # Started on 03/22/16 21:29:18 3 | # Starting class: TestAnotherThing 4 | # Starting test: TestAnotherThing.test1_Success1 5 | # Starting test: TestAnotherThing.test1_Success2 6 | # Starting test: TestAnotherThing.test3_Fail1 7 | # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 8 | # Starting test: TestAnotherThing.test3_Fail2 9 | # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 10 | # Starting class: TestSomething 11 | # Starting test: TestSomething.test1_Success1 12 | # Starting test: TestSomething.test1_Success2 13 | # Starting test: TestSomething.test2_Fail1 14 | # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 15 | # Starting test: TestSomething.test2_Fail2 16 | # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 17 | # Starting test: testFuncFail1 18 | # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 19 | # Starting test: testFuncSuccess1 20 | # Ran 10 tests in 0.002 seconds, 5 successes, 5 failures, 5 non-selected 21 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextDefault-failures.txt: -------------------------------------------------------------------------------- 1 | ..FF..FFF. 2 | Failed tests: 3 | ------------- 4 | 1) TestAnotherThing.test3_Fail1 5 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 6 | stack traceback: 7 | test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 8 | 9 | 2) TestAnotherThing.test3_Fail2 10 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 11 | stack traceback: 12 | test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 13 | 14 | 3) TestSomething.test2_Fail1 15 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 16 | stack traceback: 17 | test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 18 | 19 | 4) TestSomething.test2_Fail2 20 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 21 | stack traceback: 22 | test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 23 | 24 | 5) testFuncFail1 25 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 26 | stack traceback: 27 | test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' 28 | 29 | Ran 10 tests in 0.001 seconds, 5 successes, 5 failures, 5 non-selected 30 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextQuiet-failures.txt: -------------------------------------------------------------------------------- 1 | ..FF..FFF. 2 | Failed tests: 3 | ------------- 4 | 1) TestAnotherThing.test3_Fail1 5 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 6 | stack traceback: 7 | test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 8 | 9 | 2) TestAnotherThing.test3_Fail2 10 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 11 | stack traceback: 12 | test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 13 | 14 | 3) TestSomething.test2_Fail1 15 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 16 | stack traceback: 17 | test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 18 | 19 | 4) TestSomething.test2_Fail2 20 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 21 | stack traceback: 22 | test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 23 | 24 | 5) testFuncFail1 25 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 26 | stack traceback: 27 | test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' 28 | 29 | Ran 10 tests in 0.001 seconds, 5 successes, 5 failures, 5 non-selected 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # ignore temp files 3 | *.sw? 4 | *.bak 5 | *.pyc 6 | 7 | #ignore thumbnails created by windows 8 | Thumbs.db 9 | 10 | #Ignore files build by Visual Studio 11 | *.obj 12 | *.exe 13 | *.pdb 14 | *.user 15 | *.aps 16 | *.pch 17 | *.vspscc 18 | *_i.c 19 | *_p.c 20 | *.ncb 21 | *.suo 22 | *.tlb 23 | *.tlh 24 | *.cache 25 | *.ilk 26 | *.log 27 | [Bb]in 28 | [Dd]ebug*/ 29 | *.lib 30 | *.sbr 31 | obj/ 32 | [Rr]elease*/ 33 | _ReSharper*/ 34 | 35 | # LuaCov output (stats and report) 36 | luacov.*.out 37 | 38 | # LuaUnit ignores 39 | [Tt]est[Rr]esult* 40 | *.sublime-project 41 | *.lsln 42 | *.sublime-workspace 43 | doc/_build/ 44 | doc/html/ 45 | junit_stdout.txt 46 | output_junit.xml 47 | junit_stdout?.txt 48 | output_junit?.xml 49 | test/example*.txt 50 | test/example*.xml 51 | test/testWithXml*.xml 52 | test/testWithXml*.txt 53 | test/unitTests*.xml 54 | test/unitTests*.txt 55 | test/legacyExample.txt 56 | test/legacyExampleError.txt 57 | test/compat_luaunit_v2x.txt 58 | test/errFailPass*.txt 59 | test/errFailPass*.xml 60 | test/some_lists_comparisons.txt 61 | 62 | *.diff 63 | 64 | #Emacs 65 | *~ 66 | .idea/ 67 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | 4 | os: linux 5 | 6 | env: 7 | global: 8 | - LUAROCKS=2.2.2 9 | matrix: 10 | - LUA=lua5.1 LUANUMBER=double 11 | - LUA=lua5.1 LUANUMBER=float 12 | - LUA=lua5.2 LUANUMBER=double 13 | - LUA=lua5.2 LUANUMBER=float 14 | - LUA=lua5.3 LUANUMBER=double 15 | - LUA=lua5.3 LUANUMBER=float 16 | - LUA=luajit # latest stable version (2.0.x) 17 | - LUA=luajit2.0 # current head of 2.0 branch 18 | - LUA=luajit2.1 # current head of 2.1 branch 19 | 20 | matrix: 21 | # test Mac OS X, but limit it to a single build 22 | include: 23 | - os: osx 24 | env: LUA=lua5.1 LUANUMBER=double 25 | # 'bleeding edge' LuaJIT may fail without breaking the build 26 | allow_failures: 27 | - env: LUA=luajit2.0 28 | - env: LUA=luajit2.1 29 | 30 | before_install: 31 | - source .travis/setenv_lua.sh 32 | - luarocks install luacheck 33 | - luarocks install luacov-coveralls 34 | 35 | script: 36 | - lua -v -lluacov run_unit_tests.lua --random 37 | - lua run_functional_tests.lua --coverage 38 | - luacheck *.lua test/ 39 | 40 | after_success: 41 | - luacov-coveralls -v --include %./luaunit.lua 42 | 43 | notifications: 44 | email: 45 | on_success: change 46 | on_failure: always 47 | -------------------------------------------------------------------------------- /junitxml/example-apache-ant.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 13 | Detailed failure content 14 | 15 | 16 | 20 | 22 | 23 | 25 | Detailed error content 26 | 27 | 28 | bla bla output bla bla 29 | bla bla error bla bla 30 | 31 | -------------------------------------------------------------------------------- /junitxml/example-jenkins.xml: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | 7 | 8 | 10 | 11 | bla bla 12 | 14 | Detailed failure content 15 | 16 | 17 | 19 | 20 | 22 | Detailed error content 23 | 24 | 25 | bla bla output bla bla 26 | bla bla error bla bla 27 | 28 | 29 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software is distributed under the BSD License. 2 | 3 | Copyright (c) 2005-2014, Philippe Fremy 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /junitxml/notes-junit-compatibility.txt: -------------------------------------------------------------------------------- 1 | Our source information: 2 | * http://stackoverflow.com/questions/4922867/junit-xml-format-specification-that-hudson-supports 3 | (Jenkins) 4 | * https://github.com/jenkinsci/xunit-plugin/tree/master/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd 5 | * http://help.catchsoftware.com/display/ET/JUnit+Format 6 | * http://llg.cubic.org/docs/junit/ 7 | * https://confluence.atlassian.com/bamboo/junit-parsing-in-bamboo-289277357.html 8 | * http://nose2.readthedocs.io/en/latest/plugins/junitxml.html 9 | * https://pzolee.blogs.balabit.com/2012/11/jenkins-vs-junit-xml-format/ 10 | * https://www.relishapp.com/cucumber/cucumber/docs/formatters/junit-output-formatter 11 | * http://stackoverflow.com/questions/11241781/python-unittests-in-jenkins 12 | * https://github.com/xmlrunner/unittest-xml-reporting/tree/master/ 13 | 14 | 15 | 16 | Notes: 17 | ====== 18 | Ant xml schema is much more restrictive than jenkins. 19 | 20 | Non allowed fields in ant, allowed in jenkins: 21 | 22 | testsuites: 23 | - apache ant forbids all attributes. 24 | 25 | testsuite: 26 | - apache ant forbids attributes: disabled, skipped 27 | - apache ant allows elements system-out and system-err, that are in testcase for jenkins 28 | 29 | testcase: 30 | - apache ant forbids attributes: assertions, status 31 | - apache ant forbids elements: skipped, system-out, system-err 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/ref/exampleTapDefault.txt: -------------------------------------------------------------------------------- 1 | 1..15 2 | # Started on 01/30/16 22:19:36 3 | # Starting class: TestTiti 4 | not ok 1 TestTiti.test1_withFailure 5 | example_with_luaunit.lua:104: expected: 2, actual: 1 6 | not ok 2 TestTiti.test2_withFailure 7 | example_with_luaunit.lua:113: expected: "bof" 8 | actual: "hop" 9 | ok 3 TestTiti.test3 10 | # Starting class: TestToto 11 | not ok 4 TestToto.test1_withFailure 12 | example_with_luaunit.lua:21: expected: 2, actual: 1 13 | not ok 5 TestToto.test2_withFailure 14 | example_with_luaunit.lua:30: expected: "bof" 15 | actual: "hop" 16 | ok 6 TestToto.test3 17 | not ok 7 TestToto.test4 18 | example_with_luaunit.lua:43: Received the not expected value: 1 19 | not ok 8 TestToto.test5 20 | example_with_luaunit.lua:49: expected: false or nil, actual: 1 21 | not ok 9 TestToto.test6 22 | example_with_luaunit.lua:57: expected: false, actual: nil 23 | not ok 10 TestToto.test7 24 | example_with_luaunit.lua:63: expected: {1, 2, three=3} 25 | actual: {1, 2} 26 | not ok 11 TestToto.test8a 27 | example_with_luaunit.lua:81: Bouhouhoum error! 28 | not ok 12 TestToto.test8b 29 | example_with_luaunit.lua:81: Bouhouhoum error! 30 | not ok 13 test1_withFailure 31 | example_with_luaunit.lua:129: assertion failed! 32 | not ok 14 test2_withFailure 33 | example_with_luaunit.lua:135: assertion failed! 34 | ok 15 test3 35 | # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors 36 | -------------------------------------------------------------------------------- /test/ref/testWithXmlDefault.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 13 | 14 | 15 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /test/ref/testWithXmlQuiet.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 13 | 14 | 15 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /test/ref/testWithXmlVerbose.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 13 | 14 | 15 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /test/ref/errFailPassTapVerbose-failures.txt: -------------------------------------------------------------------------------- 1 | 1..10 2 | # Started on 03/22/16 21:58:32 3 | # Starting class: TestAnotherThing 4 | ok 1 TestAnotherThing.test1_Success1 5 | ok 2 TestAnotherThing.test1_Success2 6 | not ok 3 TestAnotherThing.test3_Fail1 7 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 8 | stack traceback: 9 | test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 10 | not ok 4 TestAnotherThing.test3_Fail2 11 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 12 | stack traceback: 13 | test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 14 | # Starting class: TestSomething 15 | ok 5 TestSomething.test1_Success1 16 | ok 6 TestSomething.test1_Success2 17 | not ok 7 TestSomething.test2_Fail1 18 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 19 | stack traceback: 20 | test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 21 | not ok 8 TestSomething.test2_Fail2 22 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 23 | stack traceback: 24 | test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 25 | not ok 9 testFuncFail1 26 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 27 | stack traceback: 28 | test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' 29 | ok 10 testFuncSuccess1 30 | # Ran 10 tests in 0.000 seconds, 5 successes, 5 failures, 5 non-selected 31 | -------------------------------------------------------------------------------- /test/ref/errFailPassTapDefault.txt: -------------------------------------------------------------------------------- 1 | 1..15 2 | # Started on 03/22/16 21:58:32 3 | # Starting class: TestAnotherThing 4 | ok 1 TestAnotherThing.test1_Success1 5 | ok 2 TestAnotherThing.test1_Success2 6 | not ok 3 TestAnotherThing.test2_Err1 7 | test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 8 | not ok 4 TestAnotherThing.test2_Err2 9 | test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value 10 | not ok 5 TestAnotherThing.test3_Fail1 11 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 12 | not ok 6 TestAnotherThing.test3_Fail2 13 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 14 | # Starting class: TestSomething 15 | ok 7 TestSomething.test1_Success1 16 | ok 8 TestSomething.test1_Success2 17 | not ok 9 TestSomething.test2_Fail1 18 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 19 | not ok 10 TestSomething.test2_Fail2 20 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 21 | not ok 11 TestSomething.test3_Err1 22 | test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 23 | not ok 12 TestSomething.test3_Err2 24 | test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value 25 | not ok 13 testFuncErr1 26 | test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value 27 | not ok 14 testFuncFail1 28 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 29 | ok 15 testFuncSuccess1 30 | # Ran 15 tests in 0.003 seconds, 5 successes, 5 failures, 5 errors 31 | -------------------------------------------------------------------------------- /test/ref/exampleXmlQuiet.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/exampleXmlQuiet.xml 2 | # Started on 01/30/16 22:19:37 3 | # Starting class: TestTiti 4 | # Starting test: TestTiti.test1_withFailure 5 | # Failure: example_with_luaunit.lua:104: expected: 2, actual: 1 6 | # Starting test: TestTiti.test2_withFailure 7 | # Failure: example_with_luaunit.lua:113: expected: "bof" 8 | actual: "hop" 9 | # Starting test: TestTiti.test3 10 | # Starting class: TestToto 11 | # Starting test: TestToto.test1_withFailure 12 | # Failure: example_with_luaunit.lua:21: expected: 2, actual: 1 13 | # Starting test: TestToto.test2_withFailure 14 | # Failure: example_with_luaunit.lua:30: expected: "bof" 15 | actual: "hop" 16 | # Starting test: TestToto.test3 17 | # Starting test: TestToto.test4 18 | # Failure: example_with_luaunit.lua:43: Received the not expected value: 1 19 | # Starting test: TestToto.test5 20 | # Failure: example_with_luaunit.lua:49: expected: false or nil, actual: 1 21 | # Starting test: TestToto.test6 22 | # Failure: example_with_luaunit.lua:57: expected: false, actual: nil 23 | # Starting test: TestToto.test7 24 | # Failure: example_with_luaunit.lua:63: expected: {1, 2, three=3} 25 | actual: {1, 2} 26 | # Starting test: TestToto.test8a 27 | # Error: example_with_luaunit.lua:81: Bouhouhoum error! 28 | # Starting test: TestToto.test8b 29 | # Error: example_with_luaunit.lua:81: Bouhouhoum error! 30 | # Starting test: test1_withFailure 31 | # Error: example_with_luaunit.lua:129: assertion failed! 32 | # Starting test: test2_withFailure 33 | # Error: example_with_luaunit.lua:135: assertion failed! 34 | # Starting test: test3 35 | # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors 36 | -------------------------------------------------------------------------------- /test/ref/exampleXmlDefault.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/exampleXmlDefault.xml 2 | # Started on 01/30/16 22:19:37 3 | # Starting class: TestTiti 4 | # Starting test: TestTiti.test1_withFailure 5 | # Failure: example_with_luaunit.lua:104: expected: 2, actual: 1 6 | # Starting test: TestTiti.test2_withFailure 7 | # Failure: example_with_luaunit.lua:113: expected: "bof" 8 | actual: "hop" 9 | # Starting test: TestTiti.test3 10 | # Starting class: TestToto 11 | # Starting test: TestToto.test1_withFailure 12 | # Failure: example_with_luaunit.lua:21: expected: 2, actual: 1 13 | # Starting test: TestToto.test2_withFailure 14 | # Failure: example_with_luaunit.lua:30: expected: "bof" 15 | actual: "hop" 16 | # Starting test: TestToto.test3 17 | # Starting test: TestToto.test4 18 | # Failure: example_with_luaunit.lua:43: Received the not expected value: 1 19 | # Starting test: TestToto.test5 20 | # Failure: example_with_luaunit.lua:49: expected: false or nil, actual: 1 21 | # Starting test: TestToto.test6 22 | # Failure: example_with_luaunit.lua:57: expected: false, actual: nil 23 | # Starting test: TestToto.test7 24 | # Failure: example_with_luaunit.lua:63: expected: {1, 2, three=3} 25 | actual: {1, 2} 26 | # Starting test: TestToto.test8a 27 | # Error: example_with_luaunit.lua:81: Bouhouhoum error! 28 | # Starting test: TestToto.test8b 29 | # Error: example_with_luaunit.lua:81: Bouhouhoum error! 30 | # Starting test: test1_withFailure 31 | # Error: example_with_luaunit.lua:129: assertion failed! 32 | # Starting test: test2_withFailure 33 | # Error: example_with_luaunit.lua:135: assertion failed! 34 | # Starting test: test3 35 | # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors 36 | -------------------------------------------------------------------------------- /test/ref/exampleXmlVerbose.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/exampleXmlVerbose.xml 2 | # Started on 01/30/16 22:19:37 3 | # Starting class: TestTiti 4 | # Starting test: TestTiti.test1_withFailure 5 | # Failure: example_with_luaunit.lua:104: expected: 2, actual: 1 6 | # Starting test: TestTiti.test2_withFailure 7 | # Failure: example_with_luaunit.lua:113: expected: "bof" 8 | actual: "hop" 9 | # Starting test: TestTiti.test3 10 | # Starting class: TestToto 11 | # Starting test: TestToto.test1_withFailure 12 | # Failure: example_with_luaunit.lua:21: expected: 2, actual: 1 13 | # Starting test: TestToto.test2_withFailure 14 | # Failure: example_with_luaunit.lua:30: expected: "bof" 15 | actual: "hop" 16 | # Starting test: TestToto.test3 17 | # Starting test: TestToto.test4 18 | # Failure: example_with_luaunit.lua:43: Received the not expected value: 1 19 | # Starting test: TestToto.test5 20 | # Failure: example_with_luaunit.lua:49: expected: false or nil, actual: 1 21 | # Starting test: TestToto.test6 22 | # Failure: example_with_luaunit.lua:57: expected: false, actual: nil 23 | # Starting test: TestToto.test7 24 | # Failure: example_with_luaunit.lua:63: expected: {1, 2, three=3} 25 | actual: {1, 2} 26 | # Starting test: TestToto.test8a 27 | # Error: example_with_luaunit.lua:81: Bouhouhoum error! 28 | # Starting test: TestToto.test8b 29 | # Error: example_with_luaunit.lua:81: Bouhouhoum error! 30 | # Starting test: test1_withFailure 31 | # Error: example_with_luaunit.lua:129: assertion failed! 32 | # Starting test: test2_withFailure 33 | # Error: example_with_luaunit.lua:135: assertion failed! 34 | # Starting test: test3 35 | # Ran 15 tests in 0.015 seconds, 3 successes, 8 failures, 4 errors 36 | -------------------------------------------------------------------------------- /test/test_with_err_fail_pass.lua: -------------------------------------------------------------------------------- 1 | local lu = require('luaunit') 2 | 3 | --[[ Test used by functional tests ]] 4 | TestSomething = {} --class 5 | 6 | function TestSomething:test1_Success1() 7 | lu.assertEquals( 1+1, 2 ) 8 | end 9 | 10 | function TestSomething:test1_Success2() 11 | lu.assertEquals( 1+2, 3 ) 12 | end 13 | 14 | function TestSomething:test2_Fail1() 15 | lu.assertEquals( 1+1, 0 ) 16 | end 17 | 18 | function TestSomething:test2_Fail2() 19 | lu.assertEquals( 1+2, 0 ) 20 | end 21 | 22 | function TestSomething:test3_Err1() 23 | local v = 1 + { 1,2 } 24 | end 25 | 26 | function TestSomething:test3_Err2() 27 | local v = 1 + { 1,2 } 28 | end 29 | 30 | TestAnotherThing = {} --class 31 | 32 | function TestAnotherThing:test1_Success1() 33 | lu.assertEquals( 1+1, 2 ) 34 | end 35 | 36 | function TestAnotherThing:test1_Success2() 37 | lu.assertEquals( 1+2, 3 ) 38 | end 39 | 40 | function TestAnotherThing:test2_Err1() 41 | local v = 1 + { 1,2 } 42 | end 43 | 44 | function TestAnotherThing:test2_Err2() 45 | local v = 1 + { 1,2 } 46 | end 47 | 48 | function TestAnotherThing:test3_Fail1() 49 | lu.assertEquals( 1+1, 0 ) 50 | end 51 | 52 | function TestAnotherThing:test3_Fail2() 53 | lu.assertEquals( 1+2, 0 ) 54 | end 55 | 56 | 57 | function testFuncSuccess1() 58 | lu.assertEquals( 1+1, 2 ) 59 | end 60 | 61 | function testFuncFail1() 62 | lu.assertEquals( 1+2, 0 ) 63 | end 64 | 65 | function testFuncErr1() 66 | local v = 1 + { 1,2 } 67 | end 68 | 69 | local runner = lu.LuaUnit.new() 70 | runner:setOutputType("text") 71 | os.exit( runner:runSuite() ) 72 | -------------------------------------------------------------------------------- /luaunit-3.2.1-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "LuaUnit" 2 | version = "3.2.1-1" 3 | source = 4 | { 5 | url = "git://github.com/bluebird75/luaunit", 6 | 7 | tag = "LUAUNIT_V3_2_1" 8 | } 9 | 10 | description = 11 | { 12 | summary = "A unit testing framework for Lua", 13 | detailed = 14 | [[ 15 | Luaunit is a unit-testing framework for Lua. It allows you to write test functions and test classes with 16 | test methods, combined with setup/teardown functionality. A wide range of assertions are supported. 17 | 18 | Luaunit supports several output format, like Junit or TAP, for easier integration into Continuous Integration 19 | platforms (Jenkins, Maven, ...) . The integrated command-line options provide a flexible interface to select tests by name 20 | or patterns, control output format, set verbosity, ... 21 | 22 | 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) and Ubuntu 14.04 (see continuous build results on Travis-CI and AppVeyor) and should work on all platforms supported by Lua. 23 | It has no other dependency than Lua itself. 24 | 25 | **Important note when upgrading to version 3.1 and above** : break of backward compatibility, assertions functions are 26 | no longer exported directly to the global namespace. See [documentation](http://luaunit.readthedocs.io/en/latest/#luaunit-global-asserts) on how to adjust or restore previous behavior. 27 | 28 | ]], 29 | homepage = "http://github.com/bluebird75/luaunit", 30 | license = "BSD" 31 | } 32 | 33 | dependencies = 34 | { 35 | "lua >= 5.1" 36 | } 37 | 38 | build = 39 | { 40 | type = "builtin", 41 | modules = 42 | { 43 | luaunit = "luaunit.lua" 44 | }, 45 | -- copy_directories = { "doc/html" } 46 | } 47 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlDefault.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/errFailPassXmlDefault.xml 2 | # Started on 03/22/16 21:29:18 3 | # Starting class: TestAnotherThing 4 | # Starting test: TestAnotherThing.test1_Success1 5 | # Starting test: TestAnotherThing.test1_Success2 6 | # Starting test: TestAnotherThing.test2_Err1 7 | # Error: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 8 | # Starting test: TestAnotherThing.test2_Err2 9 | # Error: test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value 10 | # Starting test: TestAnotherThing.test3_Fail1 11 | # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 12 | # Starting test: TestAnotherThing.test3_Fail2 13 | # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 14 | # Starting class: TestSomething 15 | # Starting test: TestSomething.test1_Success1 16 | # Starting test: TestSomething.test1_Success2 17 | # Starting test: TestSomething.test2_Fail1 18 | # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 19 | # Starting test: TestSomething.test2_Fail2 20 | # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 21 | # Starting test: TestSomething.test3_Err1 22 | # Error: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 23 | # Starting test: TestSomething.test3_Err2 24 | # Error: test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value 25 | # Starting test: testFuncErr1 26 | # Error: test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value 27 | # Starting test: testFuncFail1 28 | # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 29 | # Starting test: testFuncSuccess1 30 | # Ran 15 tests in 0.004 seconds, 5 successes, 5 failures, 5 errors 31 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlQuiet.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/errFailPassXmlQuiet.xml 2 | # Started on 03/22/16 21:29:18 3 | # Starting class: TestAnotherThing 4 | # Starting test: TestAnotherThing.test1_Success1 5 | # Starting test: TestAnotherThing.test1_Success2 6 | # Starting test: TestAnotherThing.test2_Err1 7 | # Error: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 8 | # Starting test: TestAnotherThing.test2_Err2 9 | # Error: test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value 10 | # Starting test: TestAnotherThing.test3_Fail1 11 | # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 12 | # Starting test: TestAnotherThing.test3_Fail2 13 | # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 14 | # Starting class: TestSomething 15 | # Starting test: TestSomething.test1_Success1 16 | # Starting test: TestSomething.test1_Success2 17 | # Starting test: TestSomething.test2_Fail1 18 | # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 19 | # Starting test: TestSomething.test2_Fail2 20 | # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 21 | # Starting test: TestSomething.test3_Err1 22 | # Error: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 23 | # Starting test: TestSomething.test3_Err2 24 | # Error: test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value 25 | # Starting test: testFuncErr1 26 | # Error: test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value 27 | # Starting test: testFuncFail1 28 | # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 29 | # Starting test: testFuncSuccess1 30 | # Ran 15 tests in 0.003 seconds, 5 successes, 5 failures, 5 errors 31 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlVerbose.txt: -------------------------------------------------------------------------------- 1 | # XML output to test/ref/errFailPassXmlVerbose.xml 2 | # Started on 03/22/16 21:29:18 3 | # Starting class: TestAnotherThing 4 | # Starting test: TestAnotherThing.test1_Success1 5 | # Starting test: TestAnotherThing.test1_Success2 6 | # Starting test: TestAnotherThing.test2_Err1 7 | # Error: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 8 | # Starting test: TestAnotherThing.test2_Err2 9 | # Error: test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value 10 | # Starting test: TestAnotherThing.test3_Fail1 11 | # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 12 | # Starting test: TestAnotherThing.test3_Fail2 13 | # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 14 | # Starting class: TestSomething 15 | # Starting test: TestSomething.test1_Success1 16 | # Starting test: TestSomething.test1_Success2 17 | # Starting test: TestSomething.test2_Fail1 18 | # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 19 | # Starting test: TestSomething.test2_Fail2 20 | # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 21 | # Starting test: TestSomething.test3_Err1 22 | # Error: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 23 | # Starting test: TestSomething.test3_Err2 24 | # Error: test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value 25 | # Starting test: testFuncErr1 26 | # Error: test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value 27 | # Starting test: testFuncFail1 28 | # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 29 | # Starting test: testFuncSuccess1 30 | # Ran 15 tests in 0.004 seconds, 5 successes, 5 failures, 5 errors 31 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextVerbose-failures.txt: -------------------------------------------------------------------------------- 1 | Started on 03/22/16 21:29:18 2 | TestAnotherThing.test1_Success1 ... Ok 3 | TestAnotherThing.test1_Success2 ... Ok 4 | TestAnotherThing.test3_Fail1 ... FAIL 5 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 6 | TestAnotherThing.test3_Fail2 ... FAIL 7 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 8 | TestSomething.test1_Success1 ... Ok 9 | TestSomething.test1_Success2 ... Ok 10 | TestSomething.test2_Fail1 ... FAIL 11 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 12 | TestSomething.test2_Fail2 ... FAIL 13 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 14 | testFuncFail1 ... FAIL 15 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 16 | testFuncSuccess1 ... Ok 17 | ========================================================= 18 | Failed tests: 19 | ------------- 20 | 1) TestAnotherThing.test3_Fail1 21 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 22 | stack traceback: 23 | test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 24 | 25 | 2) TestAnotherThing.test3_Fail2 26 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 27 | stack traceback: 28 | test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 29 | 30 | 3) TestSomething.test2_Fail1 31 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 32 | stack traceback: 33 | test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 34 | 35 | 4) TestSomething.test2_Fail2 36 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 37 | stack traceback: 38 | test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 39 | 40 | 5) testFuncFail1 41 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 42 | stack traceback: 43 | test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' 44 | 45 | Ran 10 tests in 0.001 seconds, 5 successes, 5 failures, 5 non-selected 46 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextDefault.txt: -------------------------------------------------------------------------------- 1 | ..EEFF..FFEEEF. 2 | Failed tests: 3 | ------------- 4 | 1) TestAnotherThing.test2_Err1 5 | test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 6 | stack traceback: 7 | [C]: in function 'xpcall' 8 | 9 | 2) TestAnotherThing.test2_Err2 10 | test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value 11 | stack traceback: 12 | [C]: in function 'xpcall' 13 | 14 | 3) TestAnotherThing.test3_Fail1 15 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 16 | stack traceback: 17 | test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 18 | 19 | 4) TestAnotherThing.test3_Fail2 20 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 21 | stack traceback: 22 | test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 23 | 24 | 5) TestSomething.test2_Fail1 25 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 26 | stack traceback: 27 | test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 28 | 29 | 6) TestSomething.test2_Fail2 30 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 31 | stack traceback: 32 | test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 33 | 34 | 7) TestSomething.test3_Err1 35 | test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 36 | stack traceback: 37 | [C]: in function 'xpcall' 38 | 39 | 8) TestSomething.test3_Err2 40 | test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value 41 | stack traceback: 42 | [C]: in function 'xpcall' 43 | 44 | 9) testFuncErr1 45 | test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value 46 | stack traceback: 47 | [C]: in function 'xpcall' 48 | 49 | 10) testFuncFail1 50 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 51 | stack traceback: 52 | test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' 53 | 54 | Ran 15 tests in 0.002 seconds, 5 successes, 5 failures, 5 errors 55 | -------------------------------------------------------------------------------- /test/ref/errFailPassTextQuiet.txt: -------------------------------------------------------------------------------- 1 | ..EEFF..FFEEEF. 2 | Failed tests: 3 | ------------- 4 | 1) TestAnotherThing.test2_Err1 5 | test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 6 | stack traceback: 7 | [C]: in function 'xpcall' 8 | 9 | 2) TestAnotherThing.test2_Err2 10 | test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value 11 | stack traceback: 12 | [C]: in function 'xpcall' 13 | 14 | 3) TestAnotherThing.test3_Fail1 15 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 16 | stack traceback: 17 | test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 18 | 19 | 4) TestAnotherThing.test3_Fail2 20 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 21 | stack traceback: 22 | test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 23 | 24 | 5) TestSomething.test2_Fail1 25 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 26 | stack traceback: 27 | test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 28 | 29 | 6) TestSomething.test2_Fail2 30 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 31 | stack traceback: 32 | test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 33 | 34 | 7) TestSomething.test3_Err1 35 | test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 36 | stack traceback: 37 | [C]: in function 'xpcall' 38 | 39 | 8) TestSomething.test3_Err2 40 | test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value 41 | stack traceback: 42 | [C]: in function 'xpcall' 43 | 44 | 9) testFuncErr1 45 | test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value 46 | stack traceback: 47 | [C]: in function 'xpcall' 48 | 49 | 10) testFuncFail1 50 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 51 | stack traceback: 52 | test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' 53 | 54 | Ran 15 tests in 0.002 seconds, 5 successes, 5 failures, 5 errors 55 | -------------------------------------------------------------------------------- /test/ref/errFailPassTapVerbose.txt: -------------------------------------------------------------------------------- 1 | 1..15 2 | # Started on 03/22/16 21:58:32 3 | # Starting class: TestAnotherThing 4 | ok 1 TestAnotherThing.test1_Success1 5 | ok 2 TestAnotherThing.test1_Success2 6 | not ok 3 TestAnotherThing.test2_Err1 7 | test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 8 | stack traceback: 9 | [C]: in function 'xpcall' 10 | not ok 4 TestAnotherThing.test2_Err2 11 | test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value 12 | stack traceback: 13 | [C]: in function 'xpcall' 14 | not ok 5 TestAnotherThing.test3_Fail1 15 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 16 | stack traceback: 17 | test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 18 | not ok 6 TestAnotherThing.test3_Fail2 19 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 20 | stack traceback: 21 | test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 22 | # Starting class: TestSomething 23 | ok 7 TestSomething.test1_Success1 24 | ok 8 TestSomething.test1_Success2 25 | not ok 9 TestSomething.test2_Fail1 26 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 27 | stack traceback: 28 | test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 29 | not ok 10 TestSomething.test2_Fail2 30 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 31 | stack traceback: 32 | test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 33 | not ok 11 TestSomething.test3_Err1 34 | test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 35 | stack traceback: 36 | [C]: in function 'xpcall' 37 | not ok 12 TestSomething.test3_Err2 38 | test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value 39 | stack traceback: 40 | [C]: in function 'xpcall' 41 | not ok 13 testFuncErr1 42 | test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value 43 | stack traceback: 44 | [C]: in function 'xpcall' 45 | not ok 14 testFuncFail1 46 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 47 | stack traceback: 48 | test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' 49 | ok 15 testFuncSuccess1 50 | # Ran 15 tests in 0.000 seconds, 5 successes, 5 failures, 5 errors 51 | -------------------------------------------------------------------------------- /test/ref/exampleTextDefault.txt: -------------------------------------------------------------------------------- 1 | FF.FF.FFFFEEEE. 2 | Failed tests: 3 | ------------- 4 | 1) TestTiti.test1_withFailure 5 | example_with_luaunit.lua:104: expected: 2, actual: 1 6 | stack traceback: 7 | example_with_luaunit.lua:104: in function 'TestTiti.test1_withFailure' 8 | 9 | 2) TestTiti.test2_withFailure 10 | example_with_luaunit.lua:113: expected: "bof" 11 | actual: "hop" 12 | stack traceback: 13 | example_with_luaunit.lua:113: in function 'TestTiti.test2_withFailure' 14 | 15 | 3) TestToto.test1_withFailure 16 | example_with_luaunit.lua:21: expected: 2, actual: 1 17 | stack traceback: 18 | example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' 19 | 20 | 4) TestToto.test2_withFailure 21 | example_with_luaunit.lua:30: expected: "bof" 22 | actual: "hop" 23 | stack traceback: 24 | example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' 25 | 26 | 5) TestToto.test4 27 | example_with_luaunit.lua:43: Received the not expected value: 1 28 | stack traceback: 29 | example_with_luaunit.lua:43: in function 'TestToto.test4' 30 | 31 | 6) TestToto.test5 32 | example_with_luaunit.lua:49: expected: false or nil, actual: 1 33 | stack traceback: 34 | example_with_luaunit.lua:49: in function 'TestToto.test5' 35 | 36 | 7) TestToto.test6 37 | example_with_luaunit.lua:57: expected: false, actual: nil 38 | stack traceback: 39 | example_with_luaunit.lua:57: in function 'TestToto.test6' 40 | 41 | 8) TestToto.test7 42 | example_with_luaunit.lua:63: expected: {1, 2, three=3} 43 | actual: {1, 2} 44 | stack traceback: 45 | example_with_luaunit.lua:63: in function 'TestToto.test7' 46 | 47 | 9) TestToto.test8a 48 | example_with_luaunit.lua:81: Bouhouhoum error! 49 | stack traceback: 50 | example_with_luaunit.lua:81: in function 'funcWithError' 51 | example_with_luaunit.lua:68: in function 'TestToto.test8a' 52 | 53 | 10) TestToto.test8b 54 | example_with_luaunit.lua:81: Bouhouhoum error! 55 | stack traceback: 56 | example_with_luaunit.lua:81: in function 'funcWithError' 57 | example_with_luaunit.lua:77: in function 'funcWithFuncWithError' 58 | example_with_luaunit.lua:73: in function 'TestToto.test8b' 59 | 60 | 11) test1_withFailure 61 | example_with_luaunit.lua:129: assertion failed! 62 | stack traceback: 63 | example_with_luaunit.lua:129: in function 'test1_withFailure' 64 | 65 | 12) test2_withFailure 66 | example_with_luaunit.lua:135: assertion failed! 67 | stack traceback: 68 | example_with_luaunit.lua:135: in function 'test2_withFailure' 69 | 70 | Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors 71 | -------------------------------------------------------------------------------- /test/ref/exampleTextQuiet.txt: -------------------------------------------------------------------------------- 1 | FF.FF.FFFFEEEE. 2 | Failed tests: 3 | ------------- 4 | 1) TestTiti.test1_withFailure 5 | example_with_luaunit.lua:104: expected: 2, actual: 1 6 | stack traceback: 7 | example_with_luaunit.lua:104: in function 'TestTiti.test1_withFailure' 8 | 9 | 2) TestTiti.test2_withFailure 10 | example_with_luaunit.lua:113: expected: "bof" 11 | actual: "hop" 12 | stack traceback: 13 | example_with_luaunit.lua:113: in function 'TestTiti.test2_withFailure' 14 | 15 | 3) TestToto.test1_withFailure 16 | example_with_luaunit.lua:21: expected: 2, actual: 1 17 | stack traceback: 18 | example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' 19 | 20 | 4) TestToto.test2_withFailure 21 | example_with_luaunit.lua:30: expected: "bof" 22 | actual: "hop" 23 | stack traceback: 24 | example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' 25 | 26 | 5) TestToto.test4 27 | example_with_luaunit.lua:43: Received the not expected value: 1 28 | stack traceback: 29 | example_with_luaunit.lua:43: in function 'TestToto.test4' 30 | 31 | 6) TestToto.test5 32 | example_with_luaunit.lua:49: expected: false or nil, actual: 1 33 | stack traceback: 34 | example_with_luaunit.lua:49: in function 'TestToto.test5' 35 | 36 | 7) TestToto.test6 37 | example_with_luaunit.lua:57: expected: false, actual: nil 38 | stack traceback: 39 | example_with_luaunit.lua:57: in function 'TestToto.test6' 40 | 41 | 8) TestToto.test7 42 | example_with_luaunit.lua:63: expected: {1, 2, three=3} 43 | actual: {1, 2} 44 | stack traceback: 45 | example_with_luaunit.lua:63: in function 'TestToto.test7' 46 | 47 | 9) TestToto.test8a 48 | example_with_luaunit.lua:81: Bouhouhoum error! 49 | stack traceback: 50 | example_with_luaunit.lua:81: in function 'funcWithError' 51 | example_with_luaunit.lua:68: in function 'TestToto.test8a' 52 | 53 | 10) TestToto.test8b 54 | example_with_luaunit.lua:81: Bouhouhoum error! 55 | stack traceback: 56 | example_with_luaunit.lua:81: in function 'funcWithError' 57 | example_with_luaunit.lua:77: in function 'funcWithFuncWithError' 58 | example_with_luaunit.lua:73: in function 'TestToto.test8b' 59 | 60 | 11) test1_withFailure 61 | example_with_luaunit.lua:129: assertion failed! 62 | stack traceback: 63 | example_with_luaunit.lua:129: in function 'test1_withFailure' 64 | 65 | 12) test2_withFailure 66 | example_with_luaunit.lua:135: assertion failed! 67 | stack traceback: 68 | example_with_luaunit.lua:135: in function 'test2_withFailure' 69 | 70 | Ran 15 tests in 0.012 seconds, 3 successes, 8 failures, 4 errors 71 | -------------------------------------------------------------------------------- /test/ref/exampleTapVerbose.txt: -------------------------------------------------------------------------------- 1 | 1..15 2 | # Started on 01/30/16 22:19:36 3 | # Starting class: TestTiti 4 | not ok 1 TestTiti.test1_withFailure 5 | example_with_luaunit.lua:104: expected: 2, actual: 1 6 | stack traceback: 7 | example_with_luaunit.lua:104: in function 'TestTiti.test1_withFailure' 8 | not ok 2 TestTiti.test2_withFailure 9 | example_with_luaunit.lua:113: expected: "bof" 10 | actual: "hop" 11 | stack traceback: 12 | example_with_luaunit.lua:113: in function 'TestTiti.test2_withFailure' 13 | ok 3 TestTiti.test3 14 | # Starting class: TestToto 15 | not ok 4 TestToto.test1_withFailure 16 | example_with_luaunit.lua:21: expected: 2, actual: 1 17 | stack traceback: 18 | example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' 19 | not ok 5 TestToto.test2_withFailure 20 | example_with_luaunit.lua:30: expected: "bof" 21 | actual: "hop" 22 | stack traceback: 23 | example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' 24 | ok 6 TestToto.test3 25 | not ok 7 TestToto.test4 26 | example_with_luaunit.lua:43: Received the not expected value: 1 27 | stack traceback: 28 | example_with_luaunit.lua:43: in function 'TestToto.test4' 29 | not ok 8 TestToto.test5 30 | example_with_luaunit.lua:49: expected: false or nil, actual: 1 31 | stack traceback: 32 | example_with_luaunit.lua:49: in function 'TestToto.test5' 33 | not ok 9 TestToto.test6 34 | example_with_luaunit.lua:57: expected: false, actual: nil 35 | stack traceback: 36 | example_with_luaunit.lua:57: in function 'TestToto.test6' 37 | not ok 10 TestToto.test7 38 | example_with_luaunit.lua:63: expected: {1, 2, three=3} 39 | actual: {1, 2} 40 | stack traceback: 41 | example_with_luaunit.lua:63: in function 'TestToto.test7' 42 | not ok 11 TestToto.test8a 43 | example_with_luaunit.lua:81: Bouhouhoum error! 44 | stack traceback: 45 | example_with_luaunit.lua:81: in function 'funcWithError' 46 | example_with_luaunit.lua:68: in function 'TestToto.test8a' 47 | not ok 12 TestToto.test8b 48 | example_with_luaunit.lua:81: Bouhouhoum error! 49 | stack traceback: 50 | example_with_luaunit.lua:81: in function 'funcWithError' 51 | example_with_luaunit.lua:77: in function 'funcWithFuncWithError' 52 | example_with_luaunit.lua:73: in function 'TestToto.test8b' 53 | not ok 13 test1_withFailure 54 | example_with_luaunit.lua:129: assertion failed! 55 | stack traceback: 56 | example_with_luaunit.lua:129: in function 'test1_withFailure' 57 | not ok 14 test2_withFailure 58 | example_with_luaunit.lua:135: assertion failed! 59 | stack traceback: 60 | example_with_luaunit.lua:135: in function 'test2_withFailure' 61 | ok 15 test3 62 | # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors 63 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlDefault-failures.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlQuiet-failures.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlVerbose-failures.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /.appveyor/install-lua.cmd: -------------------------------------------------------------------------------- 1 | REM This is a batch file to help with setting up the desired Lua environment. 2 | REM It is intended to be run as "install" step from within AppVeyor. 3 | 4 | REM version numbers and file names for binaries from http://sf.net/p/luabinaries/ 5 | set VER_51=5.1.5 6 | set VER_52=5.2.4 7 | set VER_53=5.3.3 8 | set ZIP_51=lua-%VER_51%_Win32_bin.zip 9 | set ZIP_52=lua-%VER_52%_Win32_bin.zip 10 | set ZIP_53=lua-%VER_53%_Win32_bin.zip 11 | 12 | :cinst 13 | @echo off 14 | if NOT "%LUAENV%"=="cinst" goto lua51 15 | echo Chocolatey install of Lua ... 16 | if NOT EXIST "C:\Program Files (x86)\Lua\5.1\lua.exe" ( 17 | @echo on 18 | cinst lua 19 | ) else ( 20 | @echo on 21 | echo Using cached version of Lua 22 | ) 23 | set LUA="C:\Program Files (x86)\Lua\5.1\lua.exe" 24 | @echo off 25 | goto :EOF 26 | 27 | :lua51 28 | @echo off 29 | if NOT "%LUAENV%"=="lua51" goto lua52 30 | echo Setting up Lua 5.1 ... 31 | if NOT EXIST "lua51\lua5.1.exe" ( 32 | @echo on 33 | echo Fetching Lua v5.1 from internet 34 | curl -fLsS -o %ZIP_51% http://sourceforge.net/projects/luabinaries/files/%VER_51%/Tools%%20Executables/%ZIP_51%/download 35 | unzip -d lua51 %ZIP_51% 36 | ) else ( 37 | echo Using cached version of Lua v5.1 38 | ) 39 | set LUA=lua51\lua5.1.exe 40 | @echo off 41 | goto :EOF 42 | 43 | :lua52 44 | @echo off 45 | if NOT "%LUAENV%"=="lua52" goto lua53 46 | echo Setting up Lua 5.2 ... 47 | if NOT EXIST "lua52\lua52.exe" ( 48 | @echo on 49 | echo Fetching Lua v5.2 from internet 50 | curl -fLsS -o %ZIP_52% http://sourceforge.net/projects/luabinaries/files/%VER_52%/Tools%%20Executables/%ZIP_52%/download 51 | unzip -d lua52 %ZIP_52% 52 | ) else ( 53 | echo Using cached version of Lua v5.2 54 | ) 55 | @echo on 56 | set LUA=lua52\lua52.exe 57 | @echo off 58 | goto :EOF 59 | 60 | :lua53 61 | @echo off 62 | if NOT "%LUAENV%"=="lua53" goto luajit 63 | echo Setting up Lua 5.3 ... 64 | if NOT EXIST "lua53\lua53.exe" ( 65 | @echo on 66 | echo Fetching Lua v5.3 from internet 67 | curl -fLsS -o %ZIP_53% http://sourceforge.net/projects/luabinaries/files/%VER_53%/Tools%%20Executables/%ZIP_53%/download 68 | unzip -d lua53 %ZIP_53% 69 | ) else ( 70 | echo Using cached version of Lua v5.3 71 | ) 72 | @echo on 73 | set LUA=lua53\lua53.exe 74 | @echo off 75 | goto :EOF 76 | 77 | :luajit 78 | if NOT "%LUAENV%"=="luajit20" goto luajit21 79 | echo Setting up LuaJIT 2.0 ... 80 | if NOT EXIST "luajit20\luajit.exe" ( 81 | call %~dp0install-luajit.cmd LuaJIT-2.0.4 luajit20 82 | ) else ( 83 | echo Using cached version of LuaJIT 2.0 84 | ) 85 | set LUA=luajit20\luajit.exe 86 | goto :EOF 87 | 88 | :luajit21 89 | echo Setting up LuaJIT 2.1 ... 90 | if NOT EXIST "luajit21\luajit.exe" ( 91 | call %~dp0install-luajit.cmd LuaJIT-2.1.0-beta2 luajit21 92 | ) else ( 93 | echo Using cached version of LuaJIT 2.1 94 | ) 95 | set LUA=luajit21\luajit.exe 96 | -------------------------------------------------------------------------------- /doc/test_something.lua: -------------------------------------------------------------------------------- 1 | 2 | luaunit = require('luaunit') 3 | 4 | function add(v1,v2) 5 | -- add positive numbers 6 | -- return 0 if any of the numbers are 0 7 | -- error if any of the two numbers are negative 8 | if v1 < 0 or v2 < 0 then 9 | error('Can only add positive or null numbers, received '..v1..' and '..v2) 10 | end 11 | if v1 == 0 or v2 == 0 then 12 | return 0 13 | end 14 | return v1+v2 15 | end 16 | 17 | function adder(v) 18 | -- return a function that adds v to its argument using add 19 | function closure( x ) return x+v end 20 | return closure 21 | end 22 | 23 | function div(v1,v2) 24 | -- divide positive numbers 25 | -- return 0 if any of the numbers are 0 26 | -- error if any of the two numbers are negative 27 | if v1 < 0 or v2 < 0 then 28 | error('Can only divide positive or null numbers, received '..v1..' and '..v2) 29 | end 30 | if v1 == 0 or v2 == 0 then 31 | return 0 32 | end 33 | return v1/v2 34 | end 35 | 36 | 37 | 38 | TestAdd = {} 39 | function TestAdd:testAddPositive() 40 | luaunit.assertEquals(add(1,1),2) 41 | end 42 | 43 | function TestAdd:testAddZero() 44 | luaunit.assertEquals(add(1,0),0) 45 | luaunit.assertEquals(add(0,5),0) 46 | luaunit.assertEquals(add(0,0),0) 47 | end 48 | 49 | function TestAdd:testAddError() 50 | luaunit.assertErrorMsgContains('Can only add positive or null numbers, received 2 and -3', add, 2, -3) 51 | end 52 | 53 | function TestAdd:testAdder() 54 | f = adder(3) 55 | luaunit.assertIsFunction( f ) 56 | luaunit.assertEquals( f(2), 5 ) 57 | end 58 | -- end of table TestAdd 59 | 60 | TestDiv = {} 61 | function TestDiv:testDivPositive() 62 | luaunit.assertEquals(div(4,2),2) 63 | end 64 | 65 | function TestDiv:testDivZero() 66 | luaunit.assertEquals(div(4,0),0) 67 | luaunit.assertEquals(div(0,5),0) 68 | luaunit.assertEquals(div(0,0),0) 69 | end 70 | 71 | function TestDiv:testDivError() 72 | luaunit.assertErrorMsgContains('Can only divide positive or null numbers, received 2 and -3', div, 2, -3) 73 | end 74 | 75 | --[[ 76 | TestLogger = {} 77 | function TestLogger:setUp() 78 | -- define the fname to use for logging 79 | self.fname = 'mytmplog.log' 80 | -- make sure the file does not already exists 81 | os.remove(self.fname) 82 | end 83 | 84 | function TestLogger:testLoggerCreatesFile() 85 | initLog(self.fname) 86 | log('toto') 87 | f = io.open(self.fname, 'r') 88 | luaunit.assertNotNil( f ) 89 | f:close() 90 | end 91 | 92 | function TestLogger:tearDown() 93 | self.fname = 'mytmplog.log' 94 | -- cleanup our log file after all tests 95 | os.remove(self.fname) 96 | end 97 | 98 | -- end of table TestDiv 99 | ]] 100 | 101 | os.exit(luaunit.LuaUnit.run()) -------------------------------------------------------------------------------- /test/ref/errFailPassTextVerbose.txt: -------------------------------------------------------------------------------- 1 | Started on 03/22/16 21:29:18 2 | TestAnotherThing.test1_Success1 ... Ok 3 | TestAnotherThing.test1_Success2 ... Ok 4 | TestAnotherThing.test2_Err1 ... ERROR 5 | test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 6 | TestAnotherThing.test2_Err2 ... ERROR 7 | test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value 8 | TestAnotherThing.test3_Fail1 ... FAIL 9 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 10 | TestAnotherThing.test3_Fail2 ... FAIL 11 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 12 | TestSomething.test1_Success1 ... Ok 13 | TestSomething.test1_Success2 ... Ok 14 | TestSomething.test2_Fail1 ... FAIL 15 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 16 | TestSomething.test2_Fail2 ... FAIL 17 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 18 | TestSomething.test3_Err1 ... ERROR 19 | test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 20 | TestSomething.test3_Err2 ... ERROR 21 | test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value 22 | testFuncErr1 ... ERROR 23 | test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value 24 | testFuncFail1 ... FAIL 25 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 26 | testFuncSuccess1 ... Ok 27 | ========================================================= 28 | Failed tests: 29 | ------------- 30 | 1) TestAnotherThing.test2_Err1 31 | test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value 32 | stack traceback: 33 | [C]: in function 'xpcall' 34 | 35 | 2) TestAnotherThing.test2_Err2 36 | test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value 37 | stack traceback: 38 | [C]: in function 'xpcall' 39 | 40 | 3) TestAnotherThing.test3_Fail1 41 | test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 42 | stack traceback: 43 | test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 44 | 45 | 4) TestAnotherThing.test3_Fail2 46 | test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 47 | stack traceback: 48 | test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 49 | 50 | 5) TestSomething.test2_Fail1 51 | test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 52 | stack traceback: 53 | test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 54 | 55 | 6) TestSomething.test2_Fail2 56 | test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 57 | stack traceback: 58 | test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 59 | 60 | 7) TestSomething.test3_Err1 61 | test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value 62 | stack traceback: 63 | [C]: in function 'xpcall' 64 | 65 | 8) TestSomething.test3_Err2 66 | test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value 67 | stack traceback: 68 | [C]: in function 'xpcall' 69 | 70 | 9) testFuncErr1 71 | test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value 72 | stack traceback: 73 | [C]: in function 'xpcall' 74 | 75 | 10) testFuncFail1 76 | test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 77 | stack traceback: 78 | test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' 79 | 80 | Ran 15 tests in 0.001 seconds, 5 successes, 5 failures, 5 errors 81 | -------------------------------------------------------------------------------- /junitxml/example-bamboo-2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /test/ref/exampleTextVerbose.txt: -------------------------------------------------------------------------------- 1 | Started on 01/27/16 21:35:20 2 | TestTiti.test1_withFailure ... FAIL 3 | example_with_luaunit.lua:104: expected: 2, actual: 1 4 | TestTiti.test2_withFailure ... FAIL 5 | example_with_luaunit.lua:113: expected: "bof" 6 | actual: "hop" 7 | TestTiti.test3 ... Ok 8 | TestToto.test1_withFailure ... FAIL 9 | example_with_luaunit.lua:21: expected: 2, actual: 1 10 | TestToto.test2_withFailure ... FAIL 11 | example_with_luaunit.lua:30: expected: "bof" 12 | actual: "hop" 13 | TestToto.test3 ... Ok 14 | TestToto.test4 ... FAIL 15 | example_with_luaunit.lua:43: Received the not expected value: 1 16 | TestToto.test5 ... FAIL 17 | example_with_luaunit.lua:49: expected: false or nil, actual: 1 18 | TestToto.test6 ... FAIL 19 | example_with_luaunit.lua:57: expected: false, actual: nil 20 | TestToto.test7 ... FAIL 21 | example_with_luaunit.lua:63: expected: {1, 2, three=3} 22 | actual: {1, 2} 23 | TestToto.test8a ... ERROR 24 | example_with_luaunit.lua:81: Bouhouhoum error! 25 | TestToto.test8b ... ERROR 26 | example_with_luaunit.lua:81: Bouhouhoum error! 27 | test1_withFailure ... ERROR 28 | example_with_luaunit.lua:129: assertion failed! 29 | test2_withFailure ... ERROR 30 | example_with_luaunit.lua:135: assertion failed! 31 | test3 ... Ok 32 | ========================================================= 33 | Failed tests: 34 | ------------- 35 | 1) TestTiti.test1_withFailure 36 | example_with_luaunit.lua:104: expected: 2, actual: 1 37 | stack traceback: 38 | example_with_luaunit.lua:104: in function 'TestTiti.test1_withFailure' 39 | 40 | 2) TestTiti.test2_withFailure 41 | example_with_luaunit.lua:113: expected: "bof" 42 | actual: "hop" 43 | stack traceback: 44 | example_with_luaunit.lua:113: in function 'TestTiti.test2_withFailure' 45 | 46 | 3) TestToto.test1_withFailure 47 | example_with_luaunit.lua:21: expected: 2, actual: 1 48 | stack traceback: 49 | example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' 50 | 51 | 4) TestToto.test2_withFailure 52 | example_with_luaunit.lua:30: expected: "bof" 53 | actual: "hop" 54 | stack traceback: 55 | example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' 56 | 57 | 5) TestToto.test4 58 | example_with_luaunit.lua:43: Received the not expected value: 1 59 | stack traceback: 60 | example_with_luaunit.lua:43: in function 'TestToto.test4' 61 | 62 | 6) TestToto.test5 63 | example_with_luaunit.lua:49: expected: false or nil, actual: 1 64 | stack traceback: 65 | example_with_luaunit.lua:49: in function 'TestToto.test5' 66 | 67 | 7) TestToto.test6 68 | example_with_luaunit.lua:57: expected: false, actual: nil 69 | stack traceback: 70 | example_with_luaunit.lua:57: in function 'TestToto.test6' 71 | 72 | 8) TestToto.test7 73 | example_with_luaunit.lua:63: expected: {1, 2, three=3} 74 | actual: {1, 2} 75 | stack traceback: 76 | example_with_luaunit.lua:63: in function 'TestToto.test7' 77 | 78 | 9) TestToto.test8a 79 | example_with_luaunit.lua:81: Bouhouhoum error! 80 | stack traceback: 81 | example_with_luaunit.lua:81: in function 'funcWithError' 82 | example_with_luaunit.lua:68: in function 'TestToto.test8a' 83 | 84 | 10) TestToto.test8b 85 | example_with_luaunit.lua:81: Bouhouhoum error! 86 | stack traceback: 87 | example_with_luaunit.lua:81: in function 'funcWithError' 88 | example_with_luaunit.lua:77: in function 'funcWithFuncWithError' 89 | example_with_luaunit.lua:73: in function 'TestToto.test8b' 90 | 91 | 11) test1_withFailure 92 | example_with_luaunit.lua:129: assertion failed! 93 | stack traceback: 94 | example_with_luaunit.lua:129: in function 'test1_withFailure' 95 | 96 | 12) test2_withFailure 97 | example_with_luaunit.lua:135: assertion failed! 98 | stack traceback: 99 | example_with_luaunit.lua:135: in function 'test2_withFailure' 100 | 101 | Ran 15 tests in 0.004 seconds, 3 successes, 8 failures, 4 errors 102 | -------------------------------------------------------------------------------- /test/legacy_example_with_luaunit.lua: -------------------------------------------------------------------------------- 1 | EXPORT_ASSERT_TO_GLOBALS = true 2 | require('luaunit') 3 | 4 | TestToto = {} --class 5 | 6 | function TestToto:setUp() 7 | -- set up tests 8 | self.a = 1 9 | self.s = 'hop' 10 | self.t1 = {1,2,3} 11 | self.t2 = {one=1,two=2,three=3} 12 | self.t3 = {1,2,three=3} 13 | end 14 | 15 | function TestToto:test1_withFailure() 16 | print( "some stuff test 1" ) 17 | assertEquals( self.a , 1 ) 18 | -- will fail 19 | assertEquals( self.a , 2 ) 20 | assertEquals( self.a , 2 ) 21 | end 22 | 23 | function TestToto:test2_withFailure() 24 | print( "some stuff test 2" ) 25 | assertEquals( self.a , 1 ) 26 | assertEquals( self.s , 'hop' ) 27 | -- will fail 28 | assertEquals( self.s , 'bof' ) 29 | assertEquals( self.s , 'bof' ) 30 | end 31 | 32 | function TestToto:test3() 33 | print( "some stuff test 3" ) 34 | assertEquals( self.a , 1 ) 35 | assertEquals( self.s , 'hop' ) 36 | assertEquals( type(self.a), 'number' ) 37 | end 38 | 39 | function TestToto:test4() 40 | print( "some stuff test 4" ) 41 | assertNotEquals( self.a , 1 ) 42 | end 43 | 44 | function TestToto:test5() 45 | print( "some stuff test 5" ) 46 | assertTrue( self.a ) 47 | assertFalse( self.a ) 48 | end 49 | 50 | function TestToto:test6() 51 | print( "some stuff test 6" ) 52 | assertTrue( false ) 53 | end 54 | 55 | function TestToto:test7() 56 | -- assertEquals( {1,2}, self.t1 ) 57 | -- assertEquals( {1,2}, self.t2 ) 58 | assertEquals( {1,2}, self.t3 ) 59 | end 60 | 61 | function TestToto:test8a() 62 | -- failure occurs in a submethod 63 | self:funcWithError() 64 | end 65 | 66 | function TestToto:test8b() 67 | -- failure occurs in a submethod 68 | self:funcWithFuncWithError() 69 | end 70 | 71 | function TestToto:funcWithFuncWithError() 72 | self:funcWithError() 73 | end 74 | 75 | function TestToto:funcWithError() 76 | error('Bouhouhoum error!') 77 | end 78 | 79 | 80 | -- class TestToto 81 | 82 | TestTiti = {} --class 83 | function TestTiti:setUp() 84 | -- set up tests 85 | self.a = 1 86 | self.s = 'hop' 87 | print( 'TestTiti:setUp' ) 88 | end 89 | 90 | function TestTiti:tearDown() 91 | -- some tearDown() code if necessary 92 | print( 'TestTiti:tearDown' ) 93 | end 94 | 95 | function TestTiti:test1_withFailure() 96 | print( "some stuff test 1" ) 97 | assertEquals( self.a , 1 ) 98 | -- will fail 99 | assertEquals( self.a , 2 ) 100 | assertEquals( self.a , 2 ) 101 | end 102 | 103 | function TestTiti:test2_withFailure() 104 | print( "some stuff test 2" ) 105 | assertEquals( self.a , 1 ) 106 | assertEquals( self.s , 'hop' ) 107 | -- will fail 108 | assertEquals( self.s , 'bof' ) 109 | assertEquals( self.s , 'bof' ) 110 | end 111 | 112 | function TestTiti:test3() 113 | print( "some stuff test 3" ) 114 | assertEquals( self.a , 1 ) 115 | assertEquals( self.s , 'hop' ) 116 | end 117 | -- class TestTiti 118 | 119 | -- simple test functions that were written previously can be integrated 120 | -- in luaunit too 121 | function test1_withFailure() 122 | assert( 1 == 1) 123 | -- will fail 124 | assert( 1 == 2) 125 | end 126 | 127 | function test2_withFailure() 128 | assert( 'a' == 'a') 129 | -- will fail 130 | assert( 'a' == 'b') 131 | end 132 | 133 | function test3() 134 | assert( 1 == 1) 135 | assert( 'a' == 'a') 136 | end 137 | 138 | local lu = LuaUnit.new() 139 | lu:setOutputType("tap") 140 | os.exit( lu:runSuite() ) 141 | -------------------------------------------------------------------------------- /example_with_luaunit.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | 4 | local lu = require('luaunit') 5 | 6 | TestToto = {} --class 7 | 8 | function TestToto:setUp() 9 | -- set up tests 10 | self.a = 1 11 | self.s = 'hop' 12 | self.t1 = {1,2,3} 13 | self.t2 = {one=1,two=2,three=3} 14 | self.t3 = {1,2,three=3} 15 | end 16 | 17 | function TestToto:test1_withFailure() 18 | -- print( "some stuff test 1" ) 19 | lu.assertEquals( self.a , 1 ) 20 | -- will fail 21 | lu.assertEquals( self.a , 2 ) 22 | lu.assertEquals( self.a , 2 ) 23 | end 24 | 25 | function TestToto:test2_withFailure() 26 | -- print( "some stuff test 2" ) 27 | lu.assertEquals( self.a , 1 ) 28 | lu.assertEquals( self.s , 'hop' ) 29 | -- will fail 30 | lu.assertEquals( self.s , 'bof' ) 31 | lu.assertEquals( self.s , 'bof' ) 32 | end 33 | 34 | function TestToto:test3() 35 | -- print( "some stuff test 3" ) 36 | lu.assertEquals( self.a , 1 ) 37 | lu.assertEquals( self.s , 'hop' ) 38 | lu.assertEquals( type(self.a), 'number' ) 39 | end 40 | 41 | function TestToto:test4() 42 | -- print( "some stuff test 4" ) 43 | lu.assertNotEquals( self.a , 1 ) 44 | end 45 | 46 | function TestToto:test5() 47 | -- print( "some stuff test 5" ) 48 | lu.assertEvalToTrue( self.a ) 49 | lu.assertEvalToFalse( self.a ) -- will trigger the failure 50 | end 51 | 52 | function TestToto:test6() 53 | -- print( "some stuff test 6" ) 54 | lu.assertTrue( true ) 55 | lu.assertFalse( false ) 56 | lu.assertEvalToFalse( nil ) 57 | lu.assertFalse( nil ) -- trigger the failure assertFalse is strict 58 | end 59 | 60 | function TestToto:test7() 61 | -- assertEquals( {1,2}, self.t1 ) 62 | -- assertEquals( {1,2}, self.t2 ) 63 | lu.assertEquals( {1,2}, self.t3 ) 64 | end 65 | 66 | function TestToto:test8a() 67 | -- failure occurs in a submethod 68 | self:funcWithError() 69 | end 70 | 71 | function TestToto:test8b() 72 | -- failure occurs in a submethod 73 | self:funcWithFuncWithError() 74 | end 75 | 76 | function TestToto:funcWithFuncWithError() 77 | self:funcWithError() 78 | end 79 | 80 | function TestToto:funcWithError() 81 | error('Bouhouhoum error!') 82 | end 83 | 84 | 85 | -- class TestToto 86 | 87 | TestTiti = {} --class 88 | function TestTiti:setUp() 89 | -- set up tests 90 | self.a = 1 91 | self.s = 'hop' 92 | -- print( 'TestTiti:setUp' ) 93 | end 94 | 95 | function TestTiti:tearDown() 96 | -- some tearDown() code if necessary 97 | -- print( 'TestTiti:tearDown' ) 98 | end 99 | 100 | function TestTiti:test1_withFailure() 101 | -- print( "some stuff test 1" ) 102 | lu.assertEquals( self.a , 1 ) 103 | -- will fail 104 | lu.assertEquals( self.a , 2 ) 105 | lu.assertEquals( self.a , 2 ) 106 | end 107 | 108 | function TestTiti:test2_withFailure() 109 | -- print( "some stuff test 2" ) 110 | lu.assertEquals( self.a , 1 ) 111 | lu.assertEquals( self.s , 'hop' ) 112 | -- will fail 113 | lu.assertEquals( self.s , 'bof' ) 114 | lu.assertEquals( self.s , 'bof' ) 115 | end 116 | 117 | function TestTiti:test3() 118 | -- print( "some stuff test 3" ) 119 | lu.assertEquals( self.a , 1 ) 120 | lu.assertEquals( self.s , 'hop' ) 121 | end 122 | -- class TestTiti 123 | 124 | -- simple test functions that were written previously can be integrated 125 | -- in luaunit too 126 | function test1_withFailure() 127 | assert( 1 == 1) 128 | -- will fail 129 | assert( 1 == 2) 130 | end 131 | 132 | function test2_withFailure() 133 | assert( 'a' == 'a') 134 | -- will fail 135 | assert( 'a' == 'b') 136 | end 137 | 138 | function test3() 139 | assert( 1 == 1) 140 | assert( 'a' == 'a') 141 | end 142 | 143 | local runner = lu.LuaUnit.new() 144 | runner:setOutputType("tap") 145 | os.exit( runner:runSuite() ) 146 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlQuiet.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | 53 | 55 | 56 | 57 | 58 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlDefault.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | 53 | 55 | 56 | 57 | 58 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /test/ref/errFailPassXmlVerbose.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | 53 | 55 | 56 | 57 | 58 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /doit.py: -------------------------------------------------------------------------------- 1 | import subprocess, sys, os, shutil, os.path, optparse 2 | 3 | VERSION='3.2' 4 | RELEASE_NAME='luaunit-%s' % VERSION 5 | RELEASE_DIR='release/' + RELEASE_NAME + '/' 6 | RELEASE_TAG='LUAUNIT_V3_2_1' 7 | RELEASE_DIR='release/' + RELEASE_NAME + '/' 8 | TARGET_ZIP=RELEASE_NAME + '.zip' 9 | TARGET_TGZ=RELEASE_NAME + '.tgz' 10 | REPO_PATH='d:/work/luaunit/luaunit-git/luaunit2/' 11 | 12 | # LUA50='d:/program/dev/lua/lua50/lua50.exe' 13 | LUA51='d:/program/dev/lua/lua51/lua51.exe' 14 | LUA52='d:/program/dev/lua/lua52/lua52.exe' 15 | LUA53='d:/program/dev/lua/lua53/lua53.exe' 16 | 17 | ALL_LUA = ( 18 | (LUA53, 'lua 5.3'), 19 | (LUA52, 'lua 5.2'), 20 | (LUA51, 'lua 5.1'), 21 | # (LUA50, 'lua 5.0'), 22 | ) 23 | 24 | os.environ["nodosfilewarning"] = "1" 25 | 26 | def report( s ): 27 | print( '[[[[[[[[[[[[[ %s ]]]]]]]]]]]]]' % s ) 28 | 29 | def run_tests(): 30 | '''Run tests with all versions of lua''' 31 | for lua, luaversion in ALL_LUA: 32 | report( 'Running unit-tests tests with %s' % luaversion ) 33 | retcode = subprocess.call( [lua, 'run_unit_tests.lua'] ) 34 | if retcode != 0: 35 | report( 'Invalid retcode when running tests: %d' % retcode ) 36 | sys.exit( retcode ) 37 | report( 'Running functional tests tests with %s' % luaversion ) 38 | retcode = subprocess.call( [lua, 'run_functional_tests.lua'] ) 39 | if retcode != 0: 40 | report( 'Invalid retcode when running tests: %d' % retcode ) 41 | sys.exit( retcode ) 42 | run_luacheck() 43 | report( 'All tests succeed!' ) 44 | 45 | def run_luacheck(): 46 | report('Running luacheck') 47 | retcode = subprocess.call( ['luacheck.bat', '*.lua', 'test' ] ) 48 | if retcode != 0: 49 | report( 'Invalid luacheck result' ) 50 | sys.exit( retcode ) 51 | 52 | def run_example(): 53 | for lua, luaversion in ALL_LUA: 54 | report( 'Running examples with %s' % luaversion ) 55 | retcode = subprocess.call( [lua, 'example_with_luaunit.lua'] ) 56 | if retcode != 12: 57 | report( 'Invalid retcode when running examples: %d' % retcode ) 58 | sys.exit( retcode ) 59 | report( 'All examples ran!' ) 60 | 61 | 62 | def packageit(): 63 | shutil.rmtree('release', True) 64 | try: 65 | os.mkdir('release') 66 | except OSError: 67 | pass 68 | subprocess.check_call(['d:/program/utils/Git/bin/git.exe', 'clone', '--no-hardlinks', '--branch', RELEASE_TAG, REPO_PATH, RELEASE_DIR]) 69 | os.chdir( RELEASE_DIR ) 70 | 71 | # Release dir cleanup 72 | shutil.rmtree('.git') 73 | os.unlink('.gitignore') 74 | run_tests() 75 | run_example() 76 | makedoc() 77 | shutil.rmtree('doc/_build') 78 | 79 | # Packaging 80 | os.chdir('..') 81 | report('Start packaging') 82 | shutil.make_archive(RELEASE_NAME, 'zip', root_dir='.', base_dir=RELEASE_NAME ) 83 | shutil.make_archive(RELEASE_NAME, 'gztar', root_dir='.', base_dir=RELEASE_NAME ) 84 | report('Zip and tgz ready!') 85 | 86 | def help(): 87 | print( 'Available actions:') 88 | for opt in OptToFunc: 89 | print( '\t%s' % opt ) 90 | 91 | def makedoc(): 92 | os.chdir('doc') 93 | if os.path.exists('html'): 94 | shutil.rmtree('html') 95 | subprocess.check_call(['make.bat', 'html']) 96 | shutil.copytree('_build/html', 'html') 97 | os.chdir('..') 98 | 99 | def install(): 100 | installpath = '/usr/local/share/lua/' 101 | for lua, luaversion in ALL_LUA: 102 | lua,ver = luaversion.split( ) 103 | if os.path.exists(installpath+ver): 104 | shutil.copy('luaunit.lua',installpath+ver) 105 | 106 | 107 | 108 | OptToFunc = { 109 | 'runtests' : run_tests, 110 | 'luacheck' : run_luacheck, 111 | 'runexample' : run_example, 112 | 'packageit' : packageit, 113 | 'makedoc' : makedoc, 114 | 'install' : install, 115 | 'help' : help, 116 | } 117 | 118 | if __name__ == '__main__': 119 | doingNothing = True 120 | for arg in sys.argv[1:]: 121 | if arg in OptToFunc: 122 | doingNothing = False 123 | OptToFunc[arg]() 124 | else: 125 | print( 'No such action :', arg ) 126 | sys.exit(-1) 127 | 128 | if doingNothing: 129 | help() 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /junitxml/junit-jenkins.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /.travis/setup_lua.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # A script for setting up environment for travis-ci testing. 4 | # Sets up Lua and Luarocks. 5 | # LUA must be "lua5.1", "lua5.2" or "luajit". 6 | # luajit2.0 - master v2.0 7 | # luajit2.1 - master v2.1 8 | 9 | set -eufo pipefail 10 | 11 | LUAJIT_VERSION="2.0.4" 12 | LUAJIT_BASE="LuaJIT-$LUAJIT_VERSION" 13 | 14 | source .travis/platform.sh 15 | 16 | LUA_HOME_DIR=$TRAVIS_BUILD_DIR/install/lua 17 | 18 | LR_HOME_DIR=$TRAVIS_BUILD_DIR/install/luarocks 19 | 20 | mkdir $HOME/.lua 21 | 22 | LUAJIT="no" 23 | 24 | if [ "$PLATFORM" == "macosx" ]; then 25 | if [ "$LUA" == "luajit" ]; then 26 | LUAJIT="yes"; 27 | fi 28 | if [ "$LUA" == "luajit2.0" ]; then 29 | LUAJIT="yes"; 30 | fi 31 | if [ "$LUA" == "luajit2.1" ]; then 32 | LUAJIT="yes"; 33 | fi; 34 | elif [ "$(expr substr $LUA 1 6)" == "luajit" ]; then 35 | LUAJIT="yes"; 36 | fi 37 | 38 | mkdir -p "$LUA_HOME_DIR" 39 | 40 | if [ "$LUAJIT" == "yes" ]; then 41 | 42 | if [ "$LUA" == "luajit" ]; then 43 | curl --location https://github.com/LuaJIT/LuaJIT/archive/v$LUAJIT_VERSION.tar.gz | tar xz; 44 | else 45 | git clone https://github.com/LuaJIT/LuaJIT.git $LUAJIT_BASE; 46 | fi 47 | 48 | cd $LUAJIT_BASE 49 | 50 | if [ "$LUA" == "luajit2.1" ]; then 51 | git checkout v2.1; 52 | # force the INSTALL_TNAME to be luajit 53 | perl -i -pe 's/INSTALL_TNAME=.+/INSTALL_TNAME= luajit/' Makefile 54 | fi 55 | 56 | make && make install PREFIX="$LUA_HOME_DIR" 57 | 58 | ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/luajit 59 | ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/lua; 60 | 61 | else 62 | 63 | if [ "$LUA" == "lua5.1" ]; then 64 | curl http://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz 65 | cd lua-5.1.5; 66 | elif [ "$LUA" == "lua5.2" ]; then 67 | curl http://www.lua.org/ftp/lua-5.2.4.tar.gz | tar xz 68 | cd lua-5.2.4; 69 | elif [ "$LUA" == "lua5.3" ]; then 70 | curl http://www.lua.org/ftp/lua-5.3.3.tar.gz | tar xz 71 | cd lua-5.3.3; 72 | fi 73 | 74 | # adjust numerical precision if requested with LUANUMBER=float 75 | if [ "$LUANUMBER" == "float" ]; then 76 | if [ "$LUA" == "lua5.3" ]; then 77 | # for Lua 5.3 we can simply adjust the default float type 78 | perl -i -pe "s/#define LUA_FLOAT_TYPE\tLUA_FLOAT_DOUBLE/#define LUA_FLOAT_TYPE\tLUA_FLOAT_FLOAT/" src/luaconf.h 79 | else 80 | # modify the basic LUA_NUMBER type 81 | perl -i -pe 's/#define LUA_NUMBER_DOUBLE/#define LUA_NUMBER_FLOAT/' src/luaconf.h 82 | perl -i -pe "s/LUA_NUMBER\tdouble/LUA_NUMBER\tfloat/" src/luaconf.h 83 | #perl -i -pe "s/LUAI_UACNUMBER\tdouble/LUAI_UACNUMBER\tfloat/" src/luaconf.h 84 | # adjust LUA_NUMBER_SCAN (input format) 85 | perl -i -pe 's/"%lf"/"%f"/' src/luaconf.h 86 | # adjust LUA_NUMBER_FMT (output format) 87 | perl -i -pe 's/"%\.14g"/"%\.7g"/' src/luaconf.h 88 | # adjust lua_str2number conversion 89 | perl -i -pe 's/strtod\(/strtof\(/' src/luaconf.h 90 | # this one is specific to the l_mathop(x) macro of Lua 5.2 91 | perl -i -pe 's/\t\t\(x\)/\t\t\(x##f\)/' src/luaconf.h 92 | fi 93 | fi 94 | 95 | # Build Lua without backwards compatibility for testing 96 | perl -i -pe 's/-DLUA_COMPAT_(ALL|5_2)//' src/Makefile 97 | make $PLATFORM 98 | make INSTALL_TOP="$LUA_HOME_DIR" install; 99 | 100 | ln -s $LUA_HOME_DIR/bin/lua $HOME/.lua/lua 101 | ln -s $LUA_HOME_DIR/bin/luac $HOME/.lua/luac; 102 | 103 | fi 104 | 105 | cd $TRAVIS_BUILD_DIR 106 | 107 | lua -v 108 | 109 | LUAROCKS_BASE=luarocks-$LUAROCKS 110 | 111 | curl --location http://luarocks.org/releases/$LUAROCKS_BASE.tar.gz | tar xz 112 | 113 | cd $LUAROCKS_BASE 114 | 115 | if [ "$LUA" == "luajit" ]; then 116 | ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR"; 117 | elif [ "$LUA" == "luajit2.0" ]; then 118 | ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR"; 119 | elif [ "$LUA" == "luajit2.1" ]; then 120 | ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.1" --prefix="$LR_HOME_DIR"; 121 | else 122 | ./configure --with-lua="$LUA_HOME_DIR" --prefix="$LR_HOME_DIR" 123 | fi 124 | 125 | make build && make install 126 | 127 | ln -s $LR_HOME_DIR/bin/luarocks $HOME/.lua/luarocks 128 | 129 | cd $TRAVIS_BUILD_DIR 130 | 131 | luarocks --version 132 | 133 | rm -rf $LUAROCKS_BASE 134 | 135 | if [ "$LUAJIT" == "yes" ]; then 136 | rm -rf $LUAJIT_BASE; 137 | elif [ "$LUA" == "lua5.1" ]; then 138 | rm -rf lua-5.1.5; 139 | elif [ "$LUA" == "lua5.2" ]; then 140 | rm -rf lua-5.2.4; 141 | elif [ "$LUA" == "lua5.3" ]; then 142 | rm -rf lua-5.3.2; 143 | fi 144 | -------------------------------------------------------------------------------- /test/ref/exampleXmlQuiet.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 46 | 48 | 49 | 50 | 52 | 54 | 55 | 56 | 57 | 60 | 61 | 62 | 63 | 67 | 68 | 69 | 70 | 72 | 73 | 74 | 75 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /test/ref/exampleXmlDefault.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 46 | 48 | 49 | 50 | 52 | 54 | 55 | 56 | 57 | 60 | 61 | 62 | 63 | 67 | 68 | 69 | 70 | 72 | 73 | 74 | 75 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /test/ref/exampleXmlVerbose.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 46 | 48 | 49 | 50 | 52 | 54 | 55 | 56 | 57 | 60 | 61 | 62 | 63 | 67 | 68 | 69 | 70 | 72 | 73 | 74 | 75 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /test/some_lists_comparisons.lua: -------------------------------------------------------------------------------- 1 | 2 | local lu = require('luaunit') 3 | 4 | local function range(start, stop) 5 | -- return list of { start ... stop } 6 | local i 7 | local ret = {} 8 | i=start 9 | while i <= stop do 10 | table.insert(ret, i) 11 | i = i + 1 12 | end 13 | return ret 14 | end 15 | 16 | 17 | TestListCompare = {} 18 | 19 | function TestListCompare:test1() 20 | local A = { 121221, 122211, 121221, 122211, 121221, 122212, 121212, 122112, 122121, 121212, 122121 } 21 | local B = { 121221, 122211, 121221, 122211, 121221, 122212, 121212, 122112, 121221, 121212, 122121 } 22 | lu.assertEquals( A, B ) 23 | end 24 | 25 | function TestListCompare:test1b() 26 | local A = { 121221, 122211, 121221, 122112, 121212, 121122, 121212, 122122, 121212, 122112, 122112 } 27 | local B = { 121221, 122211, 121221, 122112, 121212, 121122, 121212, 122122, 121212, 122112, 121212 } 28 | lu.assertEquals( A, B ) 29 | end 30 | 31 | function TestListCompare:test1c() 32 | local A = { 122112, 122121, 111212, 122121, 122121, 121212, 121121, 121212, 121221, 122212, 112121 } 33 | local B = { 121212, 122121, 111212, 122121, 122121, 121212, 121121, 121212, 121221, 122212, 112121 } 34 | lu.assertEquals( A, B ) 35 | end 36 | 37 | 38 | -- long list of numbers, same size, swapped values 39 | function TestListCompare:test2() 40 | local x=7 41 | local A, B = range(1,20), range(1,20) 42 | B[x], B[x+1] = B[x+1], B[x] 43 | lu.assertEquals( A, B ) 44 | end 45 | 46 | -- long list of numbers, one hole 47 | function TestListCompare:test3() 48 | local x=7 49 | local A, B = range(1,20), {} 50 | local i=1 51 | while i <= #A do 52 | if i ~= x then 53 | table.insert( B, A[i] ) 54 | end 55 | i = i + 1 56 | end 57 | lu.assertEquals( A, B ) 58 | end 59 | 60 | 61 | -- long list of numbers, one bigger hole 62 | function TestListCompare:test4() 63 | local x=7 64 | local x2=8 65 | local x3=9 66 | local A, B = range(1,20), {} 67 | local i=1 68 | while i <= #A do 69 | if i ~= x and i ~= x2 and i ~= x3 then 70 | table.insert( B, A[i] ) 71 | end 72 | i = i + 1 73 | end 74 | lu.assertEquals( A, B ) 75 | end 76 | 77 | -- long list, difference + big hole 78 | function TestListCompare:sub_test5() 79 | local x=7 80 | local x2=8 81 | local x3=9 82 | local A, B = range(1,20), {} 83 | local i=1 84 | while i <= #A do 85 | if i ~= x and i ~= x2 and i ~= x3 then 86 | table.insert( B, A[i] ) 87 | end 88 | i = i + 1 89 | end 90 | x = 5 91 | B[x], B[x+1] = B[x+1], B[x] 92 | return A, B 93 | end 94 | 95 | function TestListCompare:test5a() 96 | local A, B = self:sub_test5() 97 | lu.ORDER_ACTUAL_EXPECTED = false 98 | lu.assertEquals( A, B ) 99 | end 100 | 101 | function TestListCompare:test5b() 102 | local A, B = self:sub_test5() 103 | lu.assertEquals( B, A ) 104 | end 105 | 106 | function TestListCompare:test5c() 107 | local A, B = self :sub_test5() 108 | lu.PRINT_TABLE_REF_IN_ERROR_MSG = true 109 | lu.assertEquals( B, A ) 110 | end 111 | 112 | function TestListCompare:test6() 113 | local f1 = function () return nil end 114 | local t1 = coroutine.create( function(v) local y=v+1 end ) 115 | local A = { 'aaa', 'bbb', 'ccc', f1, 1.1, 2.1, nil, true, false, t1, t1, t1 } 116 | local B = { 'aaa', 'bbb', 'ccc', f1, 1.1, 2.1, nil, false, false, t1, t1, t1 } 117 | lu.assertEquals( B, A ) 118 | end 119 | 120 | function TestListCompare:test7() 121 | local A = { {1,2,3}, {1,2}, { {1}, {2} }, { 'aa', 'cc'}, 1, 2, 1.33, 1/0, { a=1 }, {} } 122 | local B = { {1,2,3}, {1,2}, { {2}, {2} }, { 'aa', 'bb'}, 1, 2, 1.33, 1/0, { a=1 }, {} } 123 | lu.assertEquals( B, A ) 124 | end 125 | 126 | function TestListCompare:tearDown() 127 | -- cancel effect of test5a 128 | lu.ORDER_ACTUAL_EXPECTED = true 129 | -- cancel effect of test5c 130 | lu.PRINT_TABLE_REF_IN_ERROR_MSG = false 131 | end 132 | -- end TestListCompare 133 | 134 | --[[ 135 | TestDictCompare = {} 136 | function XTestDictCompare:test1() 137 | lu.assertEquals( {one=1,two=2, three=3}, {one=1,two=1, three=3} ) 138 | end 139 | 140 | function XTestDictCompare:test2() 141 | lu.assertEquals( {one=1,two=2, three=3, four=4, five=5}, {one=1,two=1, three=3, four=4, five=5} ) 142 | end 143 | -- end TestDictCompare 144 | ]] 145 | 146 | 147 | os.exit( lu.run() ) -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | TODO Future: 2 | ============ 3 | - document prettystr 4 | - add the ability to count the number of assertions that should have been executed in the test 5 | - validate output with ignored tests (0 failures or some failures) 6 | - report test duration everywhere 7 | - allow to skip tests 8 | - parametrize tests 9 | - coloured output 10 | - global setup / teardown 11 | - class setup / teardown 12 | - add date and duration to tap output 13 | - better error messages for table assertions: 14 | + expected length of X, got Y 15 | + keys differing in table 1 and 2 16 | - XML: report system information 17 | - better error messages for string differences (diffing) 18 | - print local variables upon assertion error: 19 | + debug.get_local( ) will get the local variables in the current context 20 | + debug.get_upvalue( ) will get the upvalues in the current context 21 | - see inspect for better table printing: https://github.com/kikito/inspect.lua 22 | + print list part separate from the dict part in a table 23 | + print metatables in tables 24 | - see StackTracePlus for printing more stack information: https://github.com/ignacio/StackTracePlus 25 | - how does busted deal with nested tables ? functions ? 26 | - look at serpent to see how to improve nested table printing 27 | - function should be printed as 28 | - print table of test test_filterWithPattern and see how to improve readability 29 | - align the "OK" vertically for text output 30 | - better detection of screen size 31 | - shuffle should shuffle separately classes and then class methods 32 | - catch the os.exit call with a handler or something, to avoid aborting the tests 33 | - add assertTableContains and assertTableNotContains to check the presence / absence of value in an array 34 | 35 | Nice to have: 36 | ============ 37 | - stack unwrapping like in py.test 38 | 39 | TODO for 3.3 release: 40 | =============== 41 | - look at serpent to see how to improve nested table printing 42 | - doc about scientific computing dedicated functions 43 | - doc about prettystr 44 | - doc about usage of prettystr & assertion library 45 | - fix include/exclude bug (see https://github.com/bluebird75/luaunit/pull/82 ) 46 | 47 | 48 | 49 | Done since 3.2: 50 | =============== 51 | 52 | - better error messages for list assertions: 53 | + expected length of X, got Y 54 | + index differing in table 1 and 2 55 | - more doc about assertTrue/False/... with a table 56 | - randomized testing 57 | - assertions for nan and inf 58 | - can run a tests numerous times (useful for triggering the JIT effect) 59 | - can include and exclude tests from the test list 60 | 61 | Done since 3.1: 62 | =============== 63 | x provide a luarock package. See: https://rocks.moonscript.org/modules/rjpcomputing/luaunit 64 | x make a difference between errors and failures 65 | x lua 5.3 66 | x travis lua 5.3 67 | x compatibility with LuaUnit v2.0 of rjbcomputing 68 | x provide a legacy wrapFunction() 69 | 70 | Done since 3.0: 71 | =============== 72 | x check documentation link glitch to TAP 73 | x doc: report how to handle global space pollution/restriction 74 | x doc: adapt all examples to new way of requireing luaunit 75 | x less global space pollution 76 | x doc: move description of table printing to an annex 77 | x validate well-formed XML with a DTD 78 | x validate test output (TAP, ...) with functional tests 79 | x test failures, verify that output is correct 80 | x improve testresult: contain the list of tests, with status of each test 81 | x strip luaunit stack more intelligently: exclude content of luaunit 82 | x mention mailing-list in README.md 83 | x mention version in documentation 84 | x mention mailing-list 85 | x mention the new global variable config for displaying table content 86 | x fix display of tables with recursive references 87 | x improve display of nested tables in error messages 88 | x improve display of multiline strings in error messages 89 | 90 | x Junit XML Ouptut: 91 | x test and fix xml escaping 92 | x validate xml with apache and jenkins schemas 93 | + xml format: 94 | - add proper xml formatting header 95 | - report number of failures within element 96 | - report duration 97 | - add properties describe the environment 98 | 99 | Done: 100 | ============ 101 | x add other types of output 102 | x assert with matching of the error message 103 | x finish user documentation 104 | x switch version 3.0 105 | x add assertMatch for strings 106 | x document --name 107 | x improve junit xml output (one file, choice of filename) 108 | x display number of non selected tests 109 | x assertIs with all types 110 | x mention one file distribution 111 | x improve TAP output: pre-calculate test numbers, display test summary as comment 112 | x test error messages of assertStrMatches and all error functions 113 | x assertNil + assertNotNil 114 | x readthedocs integration 115 | x add travis-ci badges to README 116 | x filter by pattern 117 | x support --version 118 | x support --help 119 | x replace methodInstance with real test name in reports 120 | x better error messages for wrong command line option, or wrong output type 121 | x control verbosity and output type with command line 122 | x display time to run all tests 123 | x move all assertions together 124 | x better error display of assertIsXXX functions 125 | x add assertContains for strings 126 | x add assertIsNumber, assertIsXXX 127 | x table assertions 128 | x sequence asserts 129 | x compatibilty tests with several version of lua 130 | x add assertNotEquals 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /junitxml/example-bamboo-1.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | junit.framework.AssertionFailedError: Should not have any errors. [Perforce client error:, Connect to server 14 | failed; check $P4PORT., TCP connect to keg failed., keg: host unknown.] expected:<0> but was:<4> 15 | at junit.framework.Assert.fail(Assert.java:47) 16 | at junit.framework.Assert.failNotEquals(Assert.java:282) 17 | at junit.framework.Assert.assertEquals(Assert.java:64) 18 | at junit.framework.Assert.assertEquals(Assert.java:201) 19 | at com.atlassian.bamboo.repository.perforce.PerforceSyncCommandTest.testUsingPerforceWhenNoFilesHaveChanged(PerforceSyncCommandTest.java:60) 20 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 21 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 22 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 23 | at java.lang.reflect.Method.invoke(Method.java:585) 24 | at junit.framework.TestCase.runTest(TestCase.java:154) 25 | at junit.framework.TestCase.runBare(TestCase.java:127) 26 | at junit.framework.TestResult$1.protect(TestResult.java:106) 27 | at junit.framework.TestResult.runProtected(TestResult.java:124) 28 | at junit.framework.TestResult.run(TestResult.java:109) 29 | at junit.framework.TestCase.run(TestCase.java:118) 30 | at junit.framework.TestSuite.runTest(TestSuite.java:208) 31 | at junit.framework.TestSuite.run(TestSuite.java:203) 32 | at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source) 33 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 34 | at java.lang.reflect.Method.invoke(Method.java:585) 35 | at org.apache.maven.surefire.battery.JUnitBattery.executeJUnit(JUnitBattery.java:242) 36 | at org.apache.maven.surefire.battery.JUnitBattery.execute(JUnitBattery.java:216) 37 | at org.apache.maven.surefire.Surefire.executeBattery(Surefire.java:215) 38 | at org.apache.maven.surefire.Surefire.run(Surefire.java:163) 39 | at org.apache.maven.surefire.Surefire.run(Surefire.java:87) 40 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 41 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 42 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 43 | at java.lang.reflect.Method.invoke(Method.java:585) 44 | at org.apache.maven.surefire.SurefireBooter.runTestsInProcess(SurefireBooter.java:313) 45 | at org.apache.maven.surefire.SurefireBooter.run(SurefireBooter.java:221) 46 | at org.apache.maven.test.SurefirePlugin.execute(SurefirePlugin.java:371) 47 | at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412) 48 | at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534) 49 | at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475) 50 | at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454) 51 | at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306) 52 | at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273) 53 | at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140) 54 | at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322) 55 | at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115) 56 | at org.apache.maven.cli.MavenCli.main(MavenCli.java:256) 57 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 58 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 59 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 60 | at java.lang.reflect.Method.invoke(Method.java:585) 61 | at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) 62 | at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) 63 | at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) 64 | at org.codehaus.classworlds.Launcher.main(Launcher.java:375) 65 | 66 | 67 | PerforceSyncCommand.command: /usr/local/bin/p4 68 | 69 | 70 | -------------------------------------------------------------------------------- /test/compat_luaunit_v2x.lua: -------------------------------------------------------------------------------- 1 | EXPORT_ASSERT_TO_GLOBALS = true 2 | local lu = require('luaunit') 3 | 4 | --[[ 5 | Use Luaunit in the v2.1 fashion and check that it still works. 6 | Exercise every luaunit v2.1 function and have it executed successfully. 7 | 8 | Coverage: 9 | x Made LuaUnit:run() method able to be called with 'run' or 'Run'. 10 | x Made LuaUnit.wrapFunctions() function able to be called with 'wrapFunctions' or 'WrapFunctions' or 'wrap_functions'. 11 | x Moved wrapFunctions to the LuaUnit module table (e.g. local LuaUnit = require( "luaunit" ); LuaUnit.wrapFunctions( ... ) ) 12 | x Added LuaUnit.is and LuaUnit.is_ helper functions. (e.g. assert( LuaUnit.isString( getString() ) ) 13 | x Added assert and assert_ 14 | x Added assertNot and assert_not_ 15 | x Added _VERSION variable to hold the LuaUnit version 16 | x Added LuaUnit:setVerbosity(lvl) method to the LuaUnit. Alias: LuaUnit:SetVerbosity() and LuaUnit:set_verbosity(). 17 | x Added table deep compare 18 | x check that wrapFunctions works 19 | x Made "testable" classes able to start with 'test' or 'Test' for their name. 20 | x Made "testable" methods able to start with 'test' or 'Test' for their name. 21 | x Made testClass:setUp() methods able to be named with 'setUp' or 'Setup' or 'setup'. 22 | x Made testClass:tearDown() methods able to be named with 'tearDown' or 'TearDown' or 'teardown'. 23 | ]] 24 | 25 | 26 | TestLuaUnitV2Compat = {} 27 | 28 | function TestLuaUnitV2Compat:testRunAliases() 29 | -- some old function 30 | assertFunction( lu.run ) 31 | assertEquals( lu.Run, lu.run ) 32 | end 33 | 34 | function TestLuaUnitV2Compat:testWrapFunctionsAliases() 35 | assertFunction( lu.wrapFunctions ) 36 | assertEquals( lu.wrapFunctions, lu.WrapFunctions ) 37 | assertEquals( lu.wrapFunctions, lu.wrap_functions ) 38 | end 39 | 40 | local function typeAsserter( goodType, badType, goodAsserter, badAsserter ) 41 | goodAsserter( goodType ) 42 | if badAsserter ~= nil then 43 | badAsserter( badType ) 44 | end 45 | end 46 | 47 | function TestLuaUnitV2Compat:testAssertType() 48 | local f = function (v) return v+1 end 49 | local t = coroutine.create( function(v) local y=v+1 end ) 50 | local typesToVerify = { 51 | -- list of: { goodType, badType, goodAsserter, badAsserter } 52 | { true, "toto", assertBoolean, assertNotBoolean }, 53 | { true, "toto", assert_boolean, assert_not_boolean }, 54 | { 1 , "toto", assertNumber, assertNotNumber }, 55 | { 1 , "toto", assert_number, assert_not_number }, 56 | { "q" , 1 , assertString, assertNotString }, 57 | { "q" , 1 , assert_string, assert_not_string }, 58 | { nil , 1 , assertNil, assertNotNil }, 59 | { nil , 1 , assert_nil, assert_not_nil }, 60 | { {1,2}, "toto", assertTable, assertNotTable }, 61 | { {1,2}, "toto", assert_table, assert_not_table }, 62 | { f , "toto", assertFunction, assertNotFunction }, 63 | { f , "toto", assert_function,assert_not_function }, 64 | { t , "toto", assertThread, assertNotThread }, 65 | { t , "toto", assert_thread, assert_not_thread }, 66 | 67 | } 68 | 69 | for _,v in ipairs( typesToVerify ) do 70 | local goodType, badType, goodAsserter, badAsserter = v[1], v[2], v[3], v[4] 71 | typeAsserter( goodType, badType, goodAsserter, badAsserter ) 72 | end 73 | 74 | assertNotUserdata( "toto" ) 75 | 76 | 77 | local typesToVerify2 = { 78 | { true, "toto", lu.isBoolean }, 79 | { true, "toto", lu.is_boolean }, 80 | { 1, "toto", lu.isNumber }, 81 | { 1, "toto", lu.is_number }, 82 | { "t", 1, lu.isString }, 83 | { "t", 1, lu.is_string }, 84 | { nil, "toto", lu.isNil }, 85 | { nil, "toto", lu.is_nil }, 86 | { {1,2},"toto", lu.isTable }, 87 | { {1,2},"toto", lu.is_table }, 88 | { f, "toto", lu.isFunction }, 89 | { f, "toto", lu.is_function }, 90 | { t, "toto", lu.isThread }, 91 | { t, "toto", lu.is_thread }, 92 | } 93 | 94 | for _,v in ipairs( typesToVerify2 ) do 95 | local goodType, badType, goodTypeVerifier = v[1], v[2], v[3] 96 | if (v[3] == nil) then 97 | print('Missing function at index '.._) 98 | assertNotNil( v[3] ) 99 | end 100 | assertTrue ( goodTypeVerifier( goodType ) ) 101 | assertFalse( goodTypeVerifier( badType ) ) 102 | end 103 | 104 | end 105 | 106 | function TestLuaUnitV2Compat:testHasVersionKey() 107 | assertNotNil( lu.VERSION ) 108 | assertString( lu.VERSION ) 109 | assertNotNil( lu._VERSION ) 110 | assertTrue( lu.is_string( lu._VERSION ) ) 111 | end 112 | 113 | function TestLuaUnitV2Compat:testTableEquality() 114 | local t1 = {1,2} 115 | local t2 = t1 116 | local t3 = {1,2} 117 | local t4 = {1,2,3} 118 | 119 | assertEquals( t1, t1 ) 120 | assertEquals( t1, t2 ) 121 | -- new in LuaUnit v2.0 , deep table compare 122 | assertEquals( t1, t3 ) 123 | assertError( assertEquals, t1, t4 ) 124 | end 125 | 126 | -- Setup 127 | local called = {} 128 | 129 | function test_w1() called.w1 = true end 130 | function test_w2() called.w2 = true end 131 | function test_w3() called.w3 = true end 132 | 133 | TestSomeFuncs = lu.wrapFunctions( 'test_w1', 'test_w2', 'test_w3' ) 134 | 135 | TestWithCap = {} 136 | function TestWithCap:setup() called.setup = true end 137 | function TestWithCap:Test1() called.t1 = true end 138 | function TestWithCap:test2() called.t2 = true end 139 | function TestWithCap:teardown() called.teardown = true end 140 | 141 | testWithoutCap = {} 142 | function testWithoutCap:Setup() called.Setup = true end 143 | function testWithoutCap:Test3() called.t3 = true end 144 | function testWithoutCap:test4() called.t4 = true end 145 | function testWithoutCap:tearDown() called.tearDown = true end 146 | 147 | TestWithUnderscore = {} 148 | function TestWithUnderscore:setUp() called.setUp = true end 149 | function TestWithUnderscore:Test1() called.t1 = true end 150 | function TestWithUnderscore:test2() called.t2 = true end 151 | function TestWithUnderscore:TearDown() called.TearDown = true end 152 | 153 | -- Run 154 | lu:setVerbosity( 1 ) 155 | lu:set_verbosity( 1 ) 156 | lu:SetVerbosity( 1 ) 157 | 158 | local results = lu.run() 159 | 160 | -- Verif 161 | assert( called.w1 == true ) 162 | assert( called.w2 == true ) 163 | assert( called.w3 == true ) 164 | assert( called.t1 == true ) 165 | assert( called.t2 == true ) 166 | assert( called.t3 == true ) 167 | assert( called.t4 == true ) 168 | assert( called.setup == true ) 169 | assert( called.setUp == true ) 170 | assert( called.Setup == true ) 171 | assert( called.teardown == true ) 172 | assert( called.tearDown == true ) 173 | assert( called.TearDown == true ) 174 | 175 | os.exit( results ) 176 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/LuaUnit.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/LuaUnit.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/LuaUnit" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/LuaUnit" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\LuaUnit.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\LuaUnit.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![License](http://img.shields.io/badge/License-BSD-green.svg)](LICENSE.txt) 2 | [![Build status](https://ci.appveyor.com/api/projects/status/us6uh4e5q597jj54?svg=true&passingText=Windows%20Build%20passing&failingText=Windows%20Build%20failed)](https://ci.appveyor.com/project/bluebird75/luaunit) 3 | [![Build Status](https://travis-ci.org/bluebird75/luaunit.svg?branch=master)](https://travis-ci.org/bluebird75/luaunit) 4 | [![Documentation Status](https://readthedocs.org/projects/luaunit/badge/?version=latest)](https://readthedocs.org/projects/luaunit/?badge=latest) 5 | [![Coverage Status](https://coveralls.io/repos/github/bluebird75/luaunit/badge.svg?branch=master)](https://coveralls.io/github/bluebird75/luaunit?branch=master) 6 | [![Downloads](https://img.shields.io/badge/downloads-10k-green.svg)](https://luarocks.org/modules/bluebird75/luaunit) 7 | 8 | ## LuaUnit 9 | by Philippe Fremy 10 | 11 | LuaUnit is a unit-testing framework for Lua. It allows you 12 | to write test functions and test classes with test methods, combined with 13 | setup/teardown functionality. A wide range of assertions are supported. 14 | 15 | LuaUnit supports several output formats, like JUnit or TAP, for easier integration 16 | into Continuous Integration platforms (Jenkins, Maven, ...). The integrated command-line 17 | options provide a flexible interface to select tests by name or patterns, control output 18 | format, set verbosity, ... 19 | 20 | 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 21 | continuous build results on [Travis-CI](https://travis-ci.org/bluebird75/luaunit) and [AppVeyor](https://ci.appveyor.com/project/bluebird75/luaunit) ) and should work on all platforms supported by Lua. 22 | It has no other dependency than Lua itself. 23 | 24 | LuaUnit is packed into a single-file. To make start using it, just add the file to your project. 25 | 26 | LuaUnit is maintained on github: 27 | https://github.com/bluebird75/luaunit 28 | 29 | For more information on LuaUnit development, please check: [Developing LuaUnit](http://luaunit.readthedocs.org/en/latest/#developing-luaunit) 30 | 31 | It is released under the BSD license. 32 | 33 | Documentation is available on 34 | [read-the-docs](http://luaunit.readthedocs.org/en/latest/) 35 | 36 | **Important note when upgrading to version 3.1 and above** : break of backward compatibility, assertions functions are 37 | no longer exported directly to the global namespace. See [documentation](http://luaunit.readthedocs.io/en/latest/#luaunit-global-asserts) on how to adjust or restore previous behavior. 38 | 39 | 40 | ## Install 41 | 42 | The version in development on github is always stable and can be used safely. 43 | 44 | **github** 45 | 46 | The simplest way to install LuaUnit is to fetch the github version: 47 | 48 | git clone git@github.com:bluebird75/luaunit.git 49 | 50 | Then copy the file luaunit.lua into your project or the Lua libs directory. 51 | 52 | On Linux, you can also install it into your Lua directories 53 | 54 | sudo python doit.py install 55 | 56 | Edit `install()` for Lua version and installation directory if that 57 | fails. It uses, by default, Linux paths that depend on the version. 58 | 59 | **LuaRocks** 60 | 61 | LuaUnit v3.2 and above are available on [LuaRocks](https://luarocks.org/modules/bluebird75/luaunit). 62 | 63 | **bower** 64 | 65 | You can also install it with bower : 66 | 67 | bower install https://github.com/bluebird75/luaunit.git. 68 | 69 | ## Contributors 70 | * [NiteHawk](https://github.com/n1tehawk) 71 | * [AbigailBuccaneer](https://github.com/AbigailBuccaneer) 72 | * [Juan Julián Merelo Guervós](https://github.com/JJ) 73 | * [Naoyuki Totani](https://github.com/ntotani) 74 | * [Jennal](https://github.com/Jennal) 75 | * [George Zhao](https://github.com/zhaozg) 76 | * kbuschelman 77 | * [Victor Seva](https://github.com/linuxmaniac) 78 | * [Urs Breu](https://github.com/ubreu) 79 | * Jim Anderson 80 | 81 | ## Successes 82 | 83 | LuaUnit is used by hundreds of projects on GitHub (see [LuaUnit search](https://github.com/search?utf8=%E2%9C%93&q=filename%3Aluaunit.lua&type=Code&ref=searchresults) ) has more than 10k download on [LuaRocks](https://luarocks.org/modules/bluebird75/luaunit) ). 84 | 85 | 86 | ### History 87 | 88 | #### Version 3.3 - in progress 89 | * assertTrue and assertFalse are now strict and only succeed with boolean 90 | * add assertEvalToTrue and assertEvalToFalse with previous assertTrue/False behavior of coercing before asserting 91 | * randomized testing 92 | 93 | #### Version 3.2 - 12. Jul 2016 94 | * distinguish between failures (failed assertion) and errors 95 | * add command-line option to stop on first error or failure 96 | * support for new versions: Lua 5.3 and LuaJIT (2.0, 2.1 beta) 97 | * validation of all lua versions on Travis CI and AppVeyor 98 | * added compatibility layer with forked luaunit v2.x 99 | * added documentation about development process 100 | * improved support for table containing keys of type table 101 | * small bug fixes, several internal improvements 102 | 103 | #### Version 3.1 - 10 Mar. 2015 104 | * luaunit no longer pollutes global namespace, unless defining EXPORT_ASSERT_TO_GLOBALS to true 105 | * fixes and validation of JUnit XML generation 106 | * strip luaunit internal information from stacktrace 107 | * general improvements of test results with duration and other details 108 | * improve printing for tables, with an option to always print table id 109 | * fix printing of recursive tables 110 | 111 | **Important note when upgrading to version 3.1** : assertions functions are 112 | no longer exported directly to the global namespace. See documentation for upgrade 113 | paths. 114 | 115 | #### Version 3.0 - 9. Oct 2014 116 | 117 | Since some people have forked LuaUnit and release some 2.x version, I am 118 | jumping the version number. 119 | 120 | - moved to Github 121 | - full documentation available in text, html and pdf at read-the-docs.org 122 | - new output format: JUnit 123 | - much better table assertions 124 | - new assertions for strings, with patterns and case insensitivity: assertStrContains, 125 | assertNotStrContains, assertNotStrIContains, assertStrIContains, assertStrMatches 126 | - new assertions for floats: assertAlmostEquals, assertNotAlmostEquals 127 | - type assertions: assertIsString, assertIsNumber, ... 128 | - error assertions: assertErrorMsgEquals, assertErrorMsgContains, assertErrorMsgMatches 129 | - improved error messages for several assertions 130 | - command-line options to select test, control output type and verbosity 131 | 132 | #### Version 2.0 133 | Unofficial fork from version 1.3 134 | - lua 5.2 module style, without global namespace pollution 135 | - setUp() may be named Setup() or setup() 136 | - tearDown() may be named Teardown() or teardown() 137 | - wrapFunction() may be called WrapFunctions() or wrap_functions() 138 | - run() may also be called Run() 139 | - table deep comparision (also available in 1.4) 140 | - control verbosity with setVerbosity() SetVerbosity() and set_verbosity() 141 | - More assertions: 142 | - is, is_, assert and assert_ (e.g. assert( LuaUnit.isString( getString() ) ) 143 | - assertNot and assert_not_ 144 | 145 | #### Version 1.5 - 8. Nov 2012 146 | - compatibility with Lua 5.1 and 5.2 147 | - better object model internally 148 | - a lot more of internal tests 149 | - several internal bug fixes 150 | - make it easy to customize the test output 151 | - running test functions no longer requires a wrapper 152 | - several level of verbosity 153 | 154 | 155 | #### Version 1.4 - 26. Jul 2012 156 | - table deep comparison 157 | - switch from X11 to more popular BSD license 158 | - add TAP output format for integration into Jenkins 159 | - official repository now on github 160 | 161 | 162 | #### Version 1.3 - 30. Oct 2007 163 | - port to lua 5.1 164 | - iterate over the test classes, methods and functions in the alphabetical order 165 | - change the default order of expected, actual in assertEquals (adjustable with USE_EXPECTED_ACTUAL_IN_ASSERT_EQUALS). 166 | 167 | 168 | #### Version 1.2 - 13. Jun 2005 169 | - first public release 170 | 171 | 172 | #### Version 1.1 173 | - move global variables to internal variables 174 | - assertion order is configurable between expected/actual or actual/expected 175 | - new assertion to check that a function call returns an error 176 | - display the calling stack when an error is spotted 177 | - two verbosity level, like in python unittest 178 | 179 | ![stats](https://stats.sylphide-consulting.com/piwik/piwik.php?idsite=37&rec=1) 180 | -------------------------------------------------------------------------------- /doc/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # LuaUnit documentation build configuration file, created by 4 | # sphinx-quickstart on Thu Aug 21 21:45:55 2014. 5 | # 6 | # This file is execfile()d with the current directory set to its 7 | # containing dir. 8 | # 9 | # Note that not all possible configuration values are present in this 10 | # autogenerated file. 11 | # 12 | # All configuration values have a default; values that are commented out 13 | # serve to show the default. 14 | 15 | import sys 16 | import os 17 | 18 | # If extensions (or modules to document with autodoc) are in another directory, 19 | # add these directories to sys.path here. If the directory is relative to the 20 | # documentation root, use os.path.abspath to make it absolute, like shown here. 21 | #sys.path.insert(0, os.path.abspath('.')) 22 | 23 | # -- General configuration ------------------------------------------------ 24 | 25 | # If your documentation needs a minimal Sphinx version, state it here. 26 | #needs_sphinx = '1.0' 27 | 28 | # Add any Sphinx extension module names here, as strings. They can be 29 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 30 | # ones. 31 | extensions = [] 32 | 33 | # Add any paths that contain templates here, relative to this directory. 34 | templates_path = ['_templates'] 35 | 36 | # The suffix of source filenames. 37 | source_suffix = '.rst' 38 | 39 | # The encoding of source files. 40 | #source_encoding = 'utf-8-sig' 41 | 42 | # The master toctree document. 43 | master_doc = 'index' 44 | 45 | # General information about the project. 46 | project = u'LuaUnit' 47 | copyright = u'2016, Philippe Fremy' 48 | 49 | # The version info for the project you're documenting, acts as replacement for 50 | # |version| and |release|, also used in various other places throughout the 51 | # built documents. 52 | # 53 | # The short X.Y version. 54 | version = '3.3' 55 | # The full version, including alpha/beta/rc tags. 56 | release = '3.3' 57 | 58 | # The language for content autogenerated by Sphinx. Refer to documentation 59 | # for a list of supported languages. 60 | #language = None 61 | 62 | # There are two options for replacing |today|: either, you set today to some 63 | # non-false value, then it is used: 64 | #today = '' 65 | # Else, today_fmt is used as the format for a strftime call. 66 | #today_fmt = '%B %d, %Y' 67 | 68 | # List of patterns, relative to source directory, that match files and 69 | # directories to ignore when looking for source files. 70 | exclude_patterns = ['_build'] 71 | 72 | # The reST default role (used for this markup: `text`) to use for all 73 | # documents. 74 | #default_role = None 75 | 76 | # If true, '()' will be appended to :func: etc. cross-reference text. 77 | add_function_parentheses = True 78 | 79 | # If true, the current module name will be prepended to all description 80 | # unit titles (such as .. function::). 81 | #add_module_names = True 82 | 83 | # If true, sectionauthor and moduleauthor directives will be shown in the 84 | # output. They are ignored by default. 85 | #show_authors = False 86 | 87 | # The name of the Pygments (syntax highlighting) style to use. 88 | pygments_style = 'sphinx' 89 | 90 | # A list of ignored prefixes for module index sorting. 91 | #modindex_common_prefix = [] 92 | 93 | # If true, keep warnings as "system message" paragraphs in the built documents. 94 | #keep_warnings = False 95 | 96 | 97 | # -- Options for HTML output ---------------------------------------------- 98 | 99 | # The theme to use for HTML and HTML Help pages. See the documentation for 100 | # a list of builtin themes. 101 | html_theme = 'default' 102 | 103 | # Theme options are theme-specific and customize the look and feel of a theme 104 | # further. For a list of options available for each theme, see the 105 | # documentation. 106 | #html_theme_options = {} 107 | 108 | # Add any paths that contain custom themes here, relative to this directory. 109 | #html_theme_path = [] 110 | 111 | # The name for this set of Sphinx documents. If None, it defaults to 112 | # " v documentation". 113 | #html_title = None 114 | 115 | # A shorter title for the navigation bar. Default is the same as html_title. 116 | #html_short_title = None 117 | 118 | # The name of an image file (relative to this directory) to place at the top 119 | # of the sidebar. 120 | #html_logo = None 121 | 122 | # The name of an image file (within the static path) to use as favicon of the 123 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 124 | # pixels large. 125 | #html_favicon = None 126 | 127 | # Add any paths that contain custom static files (such as style sheets) here, 128 | # relative to this directory. They are copied after the builtin static files, 129 | # so a file named "default.css" will overwrite the builtin "default.css". 130 | html_static_path = ['_static'] 131 | 132 | # Add any extra paths that contain custom files (such as robots.txt or 133 | # .htaccess) here, relative to this directory. These files are copied 134 | # directly to the root of the documentation. 135 | #html_extra_path = [] 136 | 137 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 138 | # using the given strftime format. 139 | html_last_updated_fmt = '%b %d, %Y' 140 | 141 | # If true, SmartyPants will be used to convert quotes and dashes to 142 | # typographically correct entities. 143 | #html_use_smartypants = True 144 | 145 | # Custom sidebar templates, maps document names to template names. 146 | #html_sidebars = {} 147 | 148 | # Additional templates that should be rendered to pages, maps page names to 149 | # template names. 150 | #html_additional_pages = {} 151 | 152 | # If false, no module index is generated. 153 | #html_domain_indices = True 154 | 155 | # If false, no index is generated. 156 | #html_use_index = True 157 | 158 | # If true, the index is split into individual pages for each letter. 159 | #html_split_index = False 160 | 161 | # If true, links to the reST sources are added to the pages. 162 | #html_show_sourcelink = True 163 | 164 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 165 | #html_show_sphinx = True 166 | 167 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 168 | #html_show_copyright = True 169 | 170 | # If true, an OpenSearch description file will be output, and all pages will 171 | # contain a tag referring to it. The value of this option must be the 172 | # base URL from which the finished HTML is served. 173 | #html_use_opensearch = '' 174 | 175 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 176 | #html_file_suffix = None 177 | 178 | # Output file base name for HTML help builder. 179 | htmlhelp_basename = 'LuaUnitdoc' 180 | 181 | 182 | # -- Options for LaTeX output --------------------------------------------- 183 | 184 | latex_elements = { 185 | # The paper size ('letterpaper' or 'a4paper'). 186 | #'papersize': 'letterpaper', 187 | 188 | # The font size ('10pt', '11pt' or '12pt'). 189 | #'pointsize': '10pt', 190 | 191 | # Additional stuff for the LaTeX preamble. 192 | #'preamble': '', 193 | } 194 | 195 | # Grouping the document tree into LaTeX files. List of tuples 196 | # (source start file, target name, title, 197 | # author, documentclass [howto, manual, or own class]). 198 | latex_documents = [ 199 | ('index', 'LuaUnit.tex', u'LuaUnit Documentation', 200 | u'Philippe Fremy', 'manual'), 201 | ] 202 | 203 | # The name of an image file (relative to this directory) to place at the top of 204 | # the title page. 205 | #latex_logo = None 206 | 207 | # For "manual" documents, if this is true, then toplevel headings are parts, 208 | # not chapters. 209 | #latex_use_parts = False 210 | 211 | # If true, show page references after internal links. 212 | #latex_show_pagerefs = False 213 | 214 | # If true, show URL addresses after external links. 215 | #latex_show_urls = False 216 | 217 | # Documents to append as an appendix to all manuals. 218 | #latex_appendices = [] 219 | 220 | # If false, no module index is generated. 221 | #latex_domain_indices = True 222 | 223 | 224 | # -- Options for manual page output --------------------------------------- 225 | 226 | # One entry per manual page. List of tuples 227 | # (source start file, name, description, authors, manual section). 228 | man_pages = [ 229 | ('index', 'luaunit', u'LuaUnit Documentation', 230 | [u'Philippe Fremy'], 1) 231 | ] 232 | 233 | # If true, show URL addresses after external links. 234 | #man_show_urls = False 235 | 236 | 237 | # -- Options for Texinfo output ------------------------------------------- 238 | 239 | # Grouping the document tree into Texinfo files. List of tuples 240 | # (source start file, target name, title, author, 241 | # dir menu entry, description, category) 242 | texinfo_documents = [ 243 | ('index', 'LuaUnit', u'LuaUnit Documentation', 244 | u'Philippe Fremy', 'LuaUnit', 'One line description of project.', 245 | 'Miscellaneous'), 246 | ] 247 | 248 | # Documents to append as an appendix to all manuals. 249 | #texinfo_appendices = [] 250 | 251 | # If false, no module index is generated. 252 | #texinfo_domain_indices = True 253 | 254 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 255 | #texinfo_show_urls = 'footnote' 256 | 257 | # If true, do not generate a @detailmenu in the "Top" node's menu. 258 | #texinfo_no_detailmenu = False 259 | 260 | -------------------------------------------------------------------------------- /junitxml/junit-apache-ant.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | JUnit test result schema for the Apache Ant JUnit and JUnitReport tasks 8 | Copyright © 2011, Windy Road Technology Pty. Limited 9 | The Apache Ant JUnit XML Schema is distributed under the terms of the GNU Lesser General Public License (LGPL) http://www.gnu.org/licenses/lgpl.html 10 | Permission to waive conditions of this license may be requested from Windy Road Support (http://windyroad.org/support). 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Contains an aggregation of testsuite results 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Derived from testsuite/@name in the non-aggregated documents 31 | 32 | 33 | 34 | 35 | Starts at '0' for the first testsuite and is incremented by 1 for each following testsuite 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Contains the results of exexuting a testsuite 48 | 49 | 50 | 51 | 52 | Properties (e.g., environment settings) set during test execution 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Indicates that the test errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. Contains as a text node relevant data for the error, e.g., a stack trace 77 | 78 | 79 | 80 | 81 | 82 | 83 | The error message. e.g., if a java exception is thrown, the return value of getMessage() 84 | 85 | 86 | 87 | 88 | The type of error that occured. e.g., if a java execption is thrown the full class name of the exception. 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | Indicates that the test failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals. Contains as a text node relevant data for the failure, e.g., a stack trace 98 | 99 | 100 | 101 | 102 | 103 | 104 | The message specified in the assert 105 | 106 | 107 | 108 | 109 | The type of the assert. 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | Name of the test method 120 | 121 | 122 | 123 | 124 | Full class name for the class the test method is in. 125 | 126 | 127 | 128 | 129 | Time taken (in seconds) to execute the test 130 | 131 | 132 | 133 | 134 | 135 | 136 | Data that was written to standard out while the test was executed 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | Data that was written to standard error while the test was executed 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | Full class name of the test for non-aggregated testsuite documents. Class name without the package for aggregated testsuites documents 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | when the test was executed. Timezone may not be specified. 168 | 169 | 170 | 171 | 172 | Host on which the tests were executed. 'localhost' should be used if the hostname cannot be determined. 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | The total number of tests in the suite 183 | 184 | 185 | 186 | 187 | The total number of tests in the suite that failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals 188 | 189 | 190 | 191 | 192 | The total number of tests in the suite that errorrd. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. 193 | 194 | 195 | 196 | 197 | Time taken (in seconds) to execute the tests in the suite 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /junitxml/XMLJUnitResultFormatter.java.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | package org.apache.tools.ant.taskdefs.optional.junit; 20 | 21 | import java.io.BufferedWriter; 22 | import java.io.IOException; 23 | import java.io.OutputStream; 24 | import java.io.OutputStreamWriter; 25 | import java.io.Writer; 26 | import java.util.Enumeration; 27 | import java.util.Hashtable; 28 | import java.util.Properties; 29 | import java.util.Date; 30 | import java.net.InetAddress; 31 | import java.net.UnknownHostException; 32 | import javax.xml.parsers.DocumentBuilder; 33 | import javax.xml.parsers.DocumentBuilderFactory; 34 | import junit.framework.AssertionFailedError; 35 | import junit.framework.Test; 36 | import org.apache.tools.ant.BuildException; 37 | import org.apache.tools.ant.util.DOMElementWriter; 38 | import org.apache.tools.ant.util.DateUtils; 39 | import org.apache.tools.ant.util.FileUtils; 40 | import org.w3c.dom.Document; 41 | import org.w3c.dom.Element; 42 | import org.w3c.dom.Text; 43 | 44 | 45 | /** 46 | * Prints XML output of the test to a specified Writer. 47 | * 48 | * @see FormatterElement 49 | */ 50 | 51 | public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstants { 52 | 53 | private static final double ONE_SECOND = 1000.0; 54 | 55 | /** constant for unnnamed testsuites/cases */ 56 | private static final String UNKNOWN = "unknown"; 57 | 58 | private static DocumentBuilder getDocumentBuilder() { 59 | try { 60 | return DocumentBuilderFactory.newInstance().newDocumentBuilder(); 61 | } catch (Exception exc) { 62 | throw new ExceptionInInitializerError(exc); 63 | } 64 | } 65 | 66 | /** 67 | * The XML document. 68 | */ 69 | private Document doc; 70 | /** 71 | * The wrapper for the whole testsuite. 72 | */ 73 | private Element rootElement; 74 | /** 75 | * Element for the current test. 76 | */ 77 | private Hashtable testElements = new Hashtable(); 78 | /** 79 | * tests that failed. 80 | */ 81 | private Hashtable failedTests = new Hashtable(); 82 | /** 83 | * Timing helper. 84 | */ 85 | private Hashtable testStarts = new Hashtable(); 86 | /** 87 | * Where to write the log to. 88 | */ 89 | private OutputStream out; 90 | 91 | /** No arg constructor. */ 92 | public XMLJUnitResultFormatter() { 93 | } 94 | 95 | /** {@inheritDoc}. */ 96 | public void setOutput(OutputStream out) { 97 | this.out = out; 98 | } 99 | 100 | /** {@inheritDoc}. */ 101 | public void setSystemOutput(String out) { 102 | formatOutput(SYSTEM_OUT, out); 103 | } 104 | 105 | /** {@inheritDoc}. */ 106 | public void setSystemError(String out) { 107 | formatOutput(SYSTEM_ERR, out); 108 | } 109 | 110 | /** 111 | * The whole testsuite started. 112 | * @param suite the testsuite. 113 | */ 114 | public void startTestSuite(JUnitTest suite) { 115 | doc = getDocumentBuilder().newDocument(); 116 | rootElement = doc.createElement(TESTSUITE); 117 | String n = suite.getName(); 118 | rootElement.setAttribute(ATTR_NAME, n == null ? UNKNOWN : n); 119 | 120 | //add the timestamp 121 | final String timestamp = DateUtils.format(new Date(), 122 | DateUtils.ISO8601_DATETIME_PATTERN); 123 | rootElement.setAttribute(TIMESTAMP, timestamp); 124 | //and the hostname. 125 | rootElement.setAttribute(HOSTNAME, getHostname()); 126 | 127 | // Output properties 128 | Element propsElement = doc.createElement(PROPERTIES); 129 | rootElement.appendChild(propsElement); 130 | Properties props = suite.getProperties(); 131 | if (props != null) { 132 | Enumeration e = props.propertyNames(); 133 | while (e.hasMoreElements()) { 134 | String name = (String) e.nextElement(); 135 | Element propElement = doc.createElement(PROPERTY); 136 | propElement.setAttribute(ATTR_NAME, name); 137 | propElement.setAttribute(ATTR_VALUE, props.getProperty(name)); 138 | propsElement.appendChild(propElement); 139 | } 140 | } 141 | } 142 | 143 | /** 144 | * get the local hostname 145 | * @return the name of the local host, or "localhost" if we cannot work it out 146 | */ 147 | private String getHostname() { 148 | try { 149 | return InetAddress.getLocalHost().getHostName(); 150 | } catch (UnknownHostException e) { 151 | return "localhost"; 152 | } 153 | } 154 | 155 | /** 156 | * The whole testsuite ended. 157 | * @param suite the testsuite. 158 | * @throws BuildException on error. 159 | */ 160 | public void endTestSuite(JUnitTest suite) throws BuildException { 161 | rootElement.setAttribute(ATTR_TESTS, "" + suite.runCount()); 162 | rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); 163 | rootElement.setAttribute(ATTR_ERRORS, "" + suite.errorCount()); 164 | rootElement.setAttribute( 165 | ATTR_TIME, "" + (suite.getRunTime() / ONE_SECOND)); 166 | if (out != null) { 167 | Writer wri = null; 168 | try { 169 | wri = new BufferedWriter(new OutputStreamWriter(out, "UTF8")); 170 | wri.write("\n"); 171 | (new DOMElementWriter()).write(rootElement, wri, 0, " "); 172 | } catch (IOException exc) { 173 | throw new BuildException("Unable to write log file", exc); 174 | } finally { 175 | if (wri != null) { 176 | try { 177 | wri.flush(); 178 | } catch (IOException ex) { 179 | // ignore 180 | } 181 | } 182 | if (out != System.out && out != System.err) { 183 | FileUtils.close(wri); 184 | } 185 | } 186 | } 187 | } 188 | 189 | /** 190 | * Interface TestListener. 191 | * 192 | *

A new Test is started. 193 | * @param t the test. 194 | */ 195 | public void startTest(Test t) { 196 | testStarts.put(t, new Long(System.currentTimeMillis())); 197 | } 198 | 199 | /** 200 | * Interface TestListener. 201 | * 202 | *

A Test is finished. 203 | * @param test the test. 204 | */ 205 | public void endTest(Test test) { 206 | // Fix for bug #5637 - if a junit.extensions.TestSetup is 207 | // used and throws an exception during setUp then startTest 208 | // would never have been called 209 | if (!testStarts.containsKey(test)) { 210 | startTest(test); 211 | } 212 | 213 | Element currentTest = null; 214 | if (!failedTests.containsKey(test)) { 215 | currentTest = doc.createElement(TESTCASE); 216 | String n = JUnitVersionHelper.getTestCaseName(test); 217 | currentTest.setAttribute(ATTR_NAME, 218 | n == null ? UNKNOWN : n); 219 | // a TestSuite can contain Tests from multiple classes, 220 | // even tests with the same name - disambiguate them. 221 | currentTest.setAttribute(ATTR_CLASSNAME, 222 | JUnitVersionHelper.getTestCaseClassName(test)); 223 | rootElement.appendChild(currentTest); 224 | testElements.put(test, currentTest); 225 | } else { 226 | currentTest = (Element) testElements.get(test); 227 | } 228 | 229 | Long l = (Long) testStarts.get(test); 230 | currentTest.setAttribute(ATTR_TIME, 231 | "" + ((System.currentTimeMillis() 232 | - l.longValue()) / ONE_SECOND)); 233 | } 234 | 235 | /** 236 | * Interface TestListener for JUnit <= 3.4. 237 | * 238 | *

A Test failed. 239 | * @param test the test. 240 | * @param t the exception. 241 | */ 242 | public void addFailure(Test test, Throwable t) { 243 | formatError(FAILURE, test, t); 244 | } 245 | 246 | /** 247 | * Interface TestListener for JUnit > 3.4. 248 | * 249 | *

A Test failed. 250 | * @param test the test. 251 | * @param t the assertion. 252 | */ 253 | public void addFailure(Test test, AssertionFailedError t) { 254 | addFailure(test, (Throwable) t); 255 | } 256 | 257 | /** 258 | * Interface TestListener. 259 | * 260 | *

An error occurred while running the test. 261 | * @param test the test. 262 | * @param t the error. 263 | */ 264 | public void addError(Test test, Throwable t) { 265 | formatError(ERROR, test, t); 266 | } 267 | 268 | private void formatError(String type, Test test, Throwable t) { 269 | if (test != null) { 270 | endTest(test); 271 | failedTests.put(test, test); 272 | } 273 | 274 | Element nested = doc.createElement(type); 275 | Element currentTest = null; 276 | if (test != null) { 277 | currentTest = (Element) testElements.get(test); 278 | } else { 279 | currentTest = rootElement; 280 | } 281 | 282 | currentTest.appendChild(nested); 283 | 284 | String message = t.getMessage(); 285 | if (message != null && message.length() > 0) { 286 | nested.setAttribute(ATTR_MESSAGE, t.getMessage()); 287 | } 288 | nested.setAttribute(ATTR_TYPE, t.getClass().getName()); 289 | 290 | String strace = JUnitTestRunner.getFilteredTrace(t); 291 | Text trace = doc.createTextNode(strace); 292 | nested.appendChild(trace); 293 | } 294 | 295 | private void formatOutput(String type, String output) { 296 | Element nested = doc.createElement(type); 297 | rootElement.appendChild(nested); 298 | nested.appendChild(doc.createCDATASection(output)); 299 | } 300 | 301 | } // XMLJUnitResultFormatter 302 | --------------------------------------------------------------------------------