lunit - Unit Testing Framework for Lua

About

Lunit is a unit testing framework for lua, written in lua. It provides currently 27 assert functions, 8 type checking functions and a few miscellaneous functions for usage as an easy unit testing framework.

To run lunit you need Lua 5.1 or newer. To find out more about Lua, please take a look at The Programming Language Lua.

To find out more about unit testing, look at Unit Test - Wikipedia, the free encyclopedia.

News

5. November 2009: Lunit Version 0.5 released.

This release adds the function assert_match_error() and should be more compatible with Darwin and Mac OS X. A few bugs were fixed.

Lunit is quite stable in the meantime.

5. January 2008: Lunit Version 0.4 released.

This is mostly a complete rewrite. It supports Lua-5.1 only, and uses the Lua module system. Included is a shell script that should make using lunit easy. Support for different test runner plugins has been added. The included default test runner is a console test runner.

The package is still not complete but was used internally for the last 2 years with great success.

22. August 2004: Lunit Version 0.3 (alpha) released.

New function lunit.wrap() to wrap a single function into a complete testcase added. Additionally, on test failures the stacktrace will shown.

18. August 2004: Lunit Version 0.2 (alpha) released.

This is the second release of lunit to the public. It fixes an ugly bug and adds a bunch of new tests to its own test suite. Everybody who downloaded the 0.1 alpha release, should upgrade as soon as possible. Additionally, all assert functions return the actual value on success like the build-in lua assert().

15. August 2004: Lunit Version 0.1 (alpha) released.

This is the first release of lunit for public review. It contains full documentation and a few examples.

Example

The example file "my_testcase.lua" with the following content:

require "lunit"

module( "my_testcase", lunit.testcase )

function test_success()
  assert_false( false, "This test never fails.")
end

function test_failure()
  fail( "This test always fails!" )
end

Run with the shell script "lunit" produces the following output:

# ./lunit my_testcase.lua
Loaded testsuite with 2 tests in 1 testcases.

    F.

2 Assertions checked.

  1) Failure (my_testcase.test_failure):
my_testcase.lua:10: failure
my_testcase.lua:10: This test always fails!

Testsuite finished (1 passed, 1 failed, 0 errors).

Documentation

Brief documentation is available: documentation-0.4.txt

Download

Lunit is available as a gziped tar archive. Examples and documentation as well as a complete self testsuite are included.

The archives are signed using GPG with my key

Old releases:

GIT Repository

Lunit source code is hosted at GitHub (https://github.com/mrothNET/lunit):

    git clone https://github.com/mrothNET/lunit.git

Copyright

Lunit is licensed under the terms of the MIT license.

Contact

Please feel free to send questions, suggestions, feature requests and bug reports to Michael Roth <mail@mroth.net>.