Discussion:
Are there any guide or best practice article for unit test with lua ?
tsong chong
2006-11-19 14:36:01 UTC
Permalink
HI, All

i wanna try some test driven development methods in lua

googled, but found nothing on this topic

have anyone seen such articles ?

thanks and regards,

Tsong Chong
Julien Hamaide
2006-11-19 17:38:46 UTC
Permalink
You should be interested in the lua unit test framework. We use it, and
it seems to meet our needs

http://www.nessie.de/mroth/lunit/

--
--

Julien Hamaide
Engineering Coach
10Tacle Studios Belgium / Elsewhere Entertainment
Leo Razoumov
2006-11-19 19:25:10 UTC
Permalink
Post by Julien Hamaide
You should be interested in the lua unit test framework. We use it, and
it seems to meet our needs
http://www.nessie.de/mroth/lunit/
According to your link lunit has no been updated since August 2004 and
the latest version is 0.3 (alpha). Does it mean that the project is in
a dormant phase?

--Leo--
Julien Hamaide
2006-11-19 21:24:11 UTC
Permalink
Post by Leo Razoumov
Post by Julien Hamaide
You should be interested in the lua unit test framework. We use it, and
it seems to meet our needs
http://www.nessie.de/mroth/lunit/
According to your link lunit has no been updated since August 2004 and
the latest version is 0.3 (alpha). Does it mean that the project is in
a dormant phase?
--Leo--
Yes, you are right, but it can be use as a base.
The framework lies in a single .lua file. We are using it with little
change to meet our c++ framework ( more a matter of coding style than
changing the behavior ).

I don't know if any change was needed to upgrade to 5.1, but I can ask.
--
--
--
Julien Hamaide
Engineering Coach
10Tacle Studios Belgium / Elsewhere Entertainment
Doug Currie
2006-11-20 00:08:00 UTC
Permalink
Post by Julien Hamaide
Post by Leo Razoumov
According to your link lunit has no been updated since August 2004 and
the latest version is 0.3 (alpha). Does it mean that the project is in
a dormant phase?
Yes, you are right, but it can be use as a base.
I noticed "lunit 0.4pre (alpha)" in
http://luaforge.net/frs/download.php/1611/lua-sqlite3-0.4.1.tar.bz2
from
http://luaforge.net/projects/lua-sqlite3/

e
--
Doug Currie
Londonderry, NH
Brian McCallister
2006-11-27 05:10:58 UTC
Permalink
FWIW, I wound up making a miniscule unit test harness for a project I
am working on:

The harness:
http://svn.i-want-a-pony.com/repos/wombat/trunk/test/moonunit.lua

Example Usage:
http://svn.i-want-a-pony.com/repos/wombat/trunk/test/test.lua

Running the Example (with some configs changed to generate failures):

***@golem:~/src/wombat/test$ ./test.lua
[basic_post_alt] pass
[map_regex2] pass
[server_says_hi] pass
[post_with_table] pass
[basic_post] pass
[request_attributes] pass
[simple] pass
[map_regex] pass
[translate_name_hook2] FAIL ./test.lua:97: expected
200 got 404
[fixups_hook] FAIL ./test.lua:109:
incorrect status code returned, expected 201 got 200
[server_version] pass
[basic_get] pass
[super_basic_config] pass
[simple_mapped] pass
[quietly] pass
[translate_name_hook] FAIL ./test.lua:91: expected
200 got 404
[simple_filter] pass
***@golem:~/src/wombat/test$

***@golem:~/src/wombat/test$ ./test.lua simple_filter
translate_name_hook
[simple_filter] pass
[translate_name_hook] FAIL ./test.lua:91: expected
200 got 404
***@golem:~/src/wombat/test$


It doesn't have anything very fancy, but it works darned well. Lua's
assert(..) does pretty much all the heavy lifting.

-Brian
Post by Doug Currie
Post by Julien Hamaide
Post by Leo Razoumov
According to your link lunit has no been updated since August 2004 and
the latest version is 0.3 (alpha). Does it mean that the project is in
a dormant phase?
Yes, you are right, but it can be use as a base.
I noticed "lunit 0.4pre (alpha)" in
http://luaforge.net/frs/download.php/1611/lua-sqlite3-0.4.1.tar.bz2
from
http://luaforge.net/projects/lua-sqlite3/
e
--
Doug Currie
Londonderry, NH
Asko Kauppi
2006-11-27 22:00:26 UTC
Permalink
The _only_ additional thing I've ever needed for unit tests, and I
use them a lot, is 'assert.fails()'.

Use such that:

assert.fails( function() ...doing something here that should
fail... end,
"Expected error message" )

The error message param is optional.

This is with a mod that makes 'assert' a table, and '__call'
metamethod point to the original assert (so it's there, too..)

The Rule of Thumb is: wear either the Tester hat, or the Developer
hat. At a time. Keep tests separate of the implementation (like test-
foo.lua).

-asko
Post by Brian McCallister
FWIW, I wound up making a miniscule unit test harness for a project
http://svn.i-want-a-pony.com/repos/wombat/trunk/test/moonunit.lua
http://svn.i-want-a-pony.com/repos/wombat/trunk/test/test.lua
[basic_post_alt] pass
[map_regex2] pass
[server_says_hi] pass
[post_with_table] pass
[basic_post] pass
[request_attributes] pass
[simple] pass
[map_regex] pass
expected 200 got 404
incorrect status code returned, expected 201 got 200
[server_version] pass
[basic_get] pass
[super_basic_config] pass
[simple_mapped] pass
[quietly] pass
expected 200 got 404
[simple_filter] pass
translate_name_hook
[simple_filter] pass
expected 200 got 404
It doesn't have anything very fancy, but it works darned well.
Lua's assert(..) does pretty much all the heavy lifting.
-Brian
Post by Doug Currie
Post by Julien Hamaide
Post by Leo Razoumov
According to your link lunit has no been updated since August 2004 and
the latest version is 0.3 (alpha). Does it mean that the project is in
a dormant phase?
Yes, you are right, but it can be use as a base.
I noticed "lunit 0.4pre (alpha)" in
http://luaforge.net/frs/download.php/1611/lua-sqlite3-0.4.1.tar.bz2
from
http://luaforge.net/projects/lua-sqlite3/
e
--
Doug Currie
Londonderry, NH
Loading...