luaunit

LuaUnit is a popular unit-testing framework for Lua, with an interface typical of xUnit libraries (Python unittest, Junit, NUnit, ...). It supports several output formats (Text, TAP, JUnit, ...) to be used directly or work with Continuous Integration platforms (Jenkins, Maven, ...).

OTHER License

Stars
569
Committers
30

Bot releases are visible (Hide)

luaunit - LuaUnit v3.4 Latest Release

Published by bluebird75 over 3 years ago

I am happy to announce a new release of LuaUnit v3.4

Version 3.4 - 02 March 2021

  • support for Lua 5.4
  • assertAlmostEquals() works also on tables and nested structures
  • choose test output style with environment variable LUAUNIT_OUTPUT
  • setOutputType() accepts the xml filename as second argument when using the format junit
  • improve printing of table information in case of cycles
  • add ability to skip tests with skip() and skipIf()
  • detect attempts to exit the test suite before it is finished running
  • add assertErrorMsgContentEquals() to validate exactly any error message
  • filter out some stack entries when printing assertions (useful when embedding LuaUnit inside another test layer) with STRIP_EXTRA_ENTRIES_IN_STACK_TRACE
  • add assertTableContains() and assertNotTableContains() to verify the presence of a given value within a table
  • remove option TABLE_EQUALS_KEYBYCONTENT, it did not make sense
  • bugfix:
    • assertIs()/assertNotIs() deals better with protected metatables
    • assertEquals() deals better with tables containing cycles of different structure
    • fix table length comparison for table returning inconsistent length
luaunit - LuaUnit v3.3

Published by bluebird75 over 6 years ago

I am happy to announce the release of LuaUnit v3.3 . The v3.2 release saw 245k download on lua rocks, I hope this release will please our users equally.

LuaUnit is a popular unit-testing framework for Lua, with an interface typical of xUnit libraries (Python unittest, Junit, NUnit, ...). It supports
several output formats (Text, TAP, JUnit, ...) to be used directly or work with Continuous Integration platforms (Jenkins, Hudson, ...).

This version can be downloaded with LuaRocks or from the GitHub project page ( https://github.com/bluebird75/luaunit ). Beware that to install with LuaRocks, you will need the version 2.4.4 released a few days ago (due to GitHub requiring a more recent wget).

My favourite update of this release is smart list difference analysis :

-- lua test code. Can you spot the difference ?
function TestListCompare:test1()
    local A = { 121221, 122211, 121221, 122211, 121221, 122212, 121212, 122112, 122121, 121212, 122121 }
    local B = { 121221, 122211, 121221, 122211, 121221, 122212, 121212, 122112, 121221, 121212, 122121 }
    lu.assertEquals( A, B )
end

$ lua test_some_lists_comparison.lua

TestListCompare.test1 ... FAIL
test/some_lists_comparisons.lua:22:

List difference analysis:
* lists A (actual) and B (expected) have the same size
* lists A and B start differing at index 9
* lists A and B are equal again from index 10
* Common parts:
  = A[1], B[1]: 121221
  = A[2], B[2]: 122211
  = A[3], B[3]: 121221
  = A[4], B[4]: 122211
  = A[5], B[5]: 121221
  = A[6], B[6]: 122212
  = A[7], B[7]: 121212
  = A[8], B[8]: 122112
* Differing parts:
  - A[9]: 122121
  + B[9]: 121221
* Common parts at the end of the lists
  = A[10], B[10]: 121212
  = A[11], B[11]: 122121

The other changes are :

  • General

    • when comparing lists with assertEquals(), failure message provides an advanced comparison of the lists
    • assertErrorMsgEquals() can check for error raised as tables
    • tests may be finished early with fail(), failIf(), success() or successIf()
    • improve printing of recursive tables
    • improvements and fixes to JUnit and TAP output
    • stricter assertTrue() and assertFalse(): they only succeed with boolean values
    • add assertEvalToTrue() and assertEvalToFalse() with previous assertTrue()/assertFalse() behavior of coercing to boolean before asserting
    • all assertion functions accept an optional extra message, to be printed along the failure
  • New command-line arguments:

  • can now shuffle tests with --shuffle or -s
  • possibility to repeat tests (for example to trigger a JIT), with --repeat NUM or -r NUM
  • more flexible test selection with inclusion (--pattern / -p) or exclusion (--exclude / -x) or combination of both
  • Scientific computing dedicated support (see documentation):

    • provide the machine epsilon in lu.EPS
    • new functions: assertNan(), assertInf(), assertPlusInf(), assertMinusInf(), assertPlusZero(), assertMinusZero()
    • in assertAlmostEquals( a, b, margin ), margin no longer provides a default value of 1E-11, the machine epsilon is used instead
  • Platform and continuous integration support:

    • validate LuaUnit on MacOs platform (thank to Travis CI)
    • validate LuaUnit with 32 bits numbers (floats) and 64 bits numbers (double)
    • add test coverage measurements thank to coveralls.io . Status: 99.76% of the code is verified.
    • use cache for AppVeyor and Travis builds
    • support for luarocks doc command
  • General doc improvements (detailed description of all output, more cross-linking between sections)

luaunit - LuaUnit v3.3 - RC1

Published by bluebird75 over 6 years ago

The release of LuaUnit v3.3 brings the following improvements :

  • General
    • when comparing lists with assertEquals(), failure message provides an advanced comparison of the lists
    • assertErrorMsgEquals() can check for error raised as tables
    • tests may be finished early with fail(), failIf(), success() or successIf()
    • improve printing of recursive tables
    • improvements and fixes to JUnit and TAP output
    • stricter assertTrue() and assertFalse(): they only succeed with boolean values
    • add assertEvalToTrue() and assertEvalToFalse() with previous assertTrue()/assertFalse() behavior of coercing to boolean before asserting
    • all assertion functions accept an optional extra message, to be printed along the failure
  • New command-line arguments:
    • can now shuffle tests with --shuffle or -s
    • possibility to repeat tests (for example to trigger a JIT), with --repeat NUM or -r NUM
    • more flexible test selection with inclusion (--pattern / -p) or exclusion (--exclude / -x) or combination of both
  • Scientific computing dedicated support (see documentation):
    • provide the machine epsilon in lu.EPS
    • new functions: assertNan(), assertInf(), assertPlusInf(), assertMinusInf(), assertPlusZero(), assertMinusZero()
    • in assertAlmostEquals( a, b, margin ), margin no longer provides a default value of 1E-11, the machine epsilon is used instead
  • Platform and continuous integration support:
    • validate LuaUnit on MacOs platform (thank to Travis CI)
    • validate LuaUnit with 32 bits numbers (floats) and 64 bits numbers (double)
    • add test coverage measurements thank to coveralls.io . Status: 99.76% of the code is verified.
    • use cache for AppVeyor and Travis builds
    • support for luarocks doc command
  • General doc improvements (detailed description of all output, more cross-linking between sections)
luaunit - LuaUnit v3.2

Published by bluebird75 about 8 years ago

Version 3.2 - 12. Jul 2016

  • distinguish between failures (failed assertion) and errors
  • add command-line option to stop on first error or failure
  • support for new versions: Lua 5.3 and LuaJIT (2.0, 2.1 beta)
  • validation of all lua versions on Travis CI and AppVeyor
  • added compatibility layer with forked luaunit v2.x
  • added documentation about development process
  • improved support for table containing keys of type table
  • small bug fixes, several internal improvements
luaunit - LuaUnit v3.1

Published by bluebird75 over 9 years ago

New in version 3.1 :

  • luaunit no longer pollutes global namespace, unless defining EXPORT_ASSERT_TO_GLOBALS to true
  • fixes and validation of JUnit XML generation
  • strip luaunit internal information from stacktrace
  • general improvements of test results with duration and other details
  • improve printing for tables, with an option to always print table id
  • fix printing of recursive tables
  • creation of a dedicated mailing list

Important note when upgrading to version 3.1 : assertions functions are
no longer exported directly to the global namespace. See documentation for upgrade
paths.

luaunit - LuaUnit v3.0

Published by bluebird75 about 10 years ago

New release with full documentation, must better table assertions, junit output support and many more improvements.

Package Rankings
Top 5.24% on Alpine-v3.18
Top 10.83% on Alpine-v3.16
Top 11.75% on Alpine-v3.17
Top 8.4% on Alpine-v3.12
Top 10.15% on Alpine-v3.10
Top 10.15% on Alpine-v3.15
Top 8.66% on Alpine-v3.11
Top 8.35% on Alpine-v3.13
Top 8.94% on Alpine-v3.14
Top 9.51% on Alpine-edge
Badges
Extracted from project README
CI Build status Documentation Status Coverage Status Downloads License CII Best Practices