Are there any guide or best practice article for unit test with lua ?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Are there any guide or best practice article for unit test with lua ?

chong tsong
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

Reply | Threaded
Open this post in threaded view
|

Re: Are there any guide or best practice article for unit test with lua ?

Julien Hamaide-2
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


Reply | Threaded
Open this post in threaded view
|

Re: Are there any guide or best practice article for unit test with lua ?

Leo Razoumov
On 11/19/06, Julien Hamaide <[hidden email]> wrote:
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--

Reply | Threaded
Open this post in threaded view
|

Re: Are there any guide or best practice article for unit test with lua ?

Julien Hamaide-2
Leo Razoumov wrote:
> On 11/19/06, Julien Hamaide <[hidden email]> wrote:
>> 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


Reply | Threaded
Open this post in threaded view
|

Re: Are there any guide or best practice article for unit test with lua ?

Doug Currie
>> 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


Reply | Threaded
Open this post in threaded view
|

Re: Are there any guide or best practice article for unit test with lua ?

Brian McCallister
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):

brianm@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
brianm@golem:~/src/wombat/test$

brianm@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
brianm@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

On Nov 19, 2006, at 4:08 PM, Doug Currie wrote:

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



Reply | Threaded
Open this post in threaded view
|

Re: Are there any guide or best practice article for unit test with lua ?

Asko Kauppi

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


Brian McCallister kirjoitti 27.11.2006 kello 7.10:

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):

brianm@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
brianm@golem:~/src/wombat/test$

brianm@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
brianm@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

On Nov 19, 2006, at 4:08 PM, Doug Currie wrote:

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