Page 1 of 2

Unit testing for mudlet-lua

Posted: Tue Jun 25, 2013 11:49 pm
by Vadi
As the current maintainer of mudlet-lua, I'm going to be adding unit test functionality to our Lua suite of scripts (eventually to the C functions as well).

The two prominent contenders for Unit Testing in Lua land are lunit and busted. lunit development has been stopped by its original author, but it has no dependencies. busted on the other hand is new, has a fair bit of unit testing features, and was created because lunit development is mostly dead. busted also integrates with travis, something that runs your tests for you when you do a commit, and I imagine notifies you about it as well.

On light of all this research, I'll be going with busted for creating tests. First tests will soon appear in my github repo, https://github.com/vadi2/mudlet-lua. If you'd like to contribute to creating tests (there are very many that need to be made), feel free to fork the repo.

Re: Unit testing for mudlet-lua

Posted: Wed Jun 26, 2013 10:21 pm
by Vadi
Progress so far: designed the test files layout and made a simple test for loading DB.lua. Going to set it up to run tests with the Travis CI today.

Re: Unit testing for mudlet-lua

Posted: Thu Jun 27, 2013 1:29 am
by Vadi
In a surprising twist, I've reverted back to using https://github.com/vadi2/mudlet-lua for mudlet-lua since the Travis CI would like me to use my own authenticated repository. Plus it makes more sense to be using this one.

Re: Unit testing for mudlet-lua

Posted: Thu Jun 27, 2013 2:13 am
by Vadi
Continuous integration is now setup: https://travis-ci.org/vadi2/mudlet-lua

So people don't have to setup busted on their own machines if they don't want to, or have to worry about re-running the tests all the time before committing.

Re: Unit testing for mudlet-lua

Posted: Tue Jul 02, 2013 4:29 pm
by demonnic
Though, as a quick note, it's generally considered bad form to commit code which breaks the tests in a project.

Re: Unit testing for mudlet-lua

Posted: Thu Aug 01, 2013 5:12 am
by Heiko
The current "tests" make very little sense to me because they are completely trivial and useless in their current form - especially as they don't contain any client testing. The color echo and insert functions are known to be buggy in mudlet-lua. This would be a useful playground for test scripts that would actually help quality control.

Re: Unit testing for mudlet-lua

Posted: Thu Aug 01, 2013 8:19 am
by Vadi
The tests are far from complete and the ones that are there, only focus on DB functionality as I was working on fixing bugs there - and created tests as I went along, so future similar problems would be caught.

If there are any bugs regarding cecho or insert functions, please file them on LP. At the moment it doesn't have any. The only known issue with cecho is a missing feature: it doesn't handle underline/bold/italics yet.

Re: Unit testing for mudlet-lua

Posted: Fri Aug 02, 2013 12:33 am
by Heiko
This test script shows various bugs related to the mudlet-lua color echo and insert functions. There's probably more.
Code: [show] | [select all] lua
echo("TEST PART1: C-API echo & insert functions: <blue>STARTING<light_blue> test#1<green>...\n")
echo("<red>red text<blue>blue text<green>and some green text\n")
moveCursor(10,getLineCount()-1)
insertText("***INSERTING***<orange>orange<pink>pink<purple>purple\ncontinuing on next line#1<green>test 2\ncontinuing on next line#2<blue>test3")

cecho("\nTEST PART2: mudlet-lua cecho & cinsert:<blue>STARTING<light_blue> test#1<green>...\n")
cecho("<red>red text<blue>blue text<green>and some green text\n")
moveCursor(10,getLineCount()-1)
insertText("***INSERTING***<orange>orange<pink>pink<purple>purple\ncontinuing on next line#1<green>test 2\ncontinuing on next line#2<blue>test3")

echo("\nRESULT: cinsert() doesn't respect inserted new lines\n")

echo("TEST PART3: testing cecho() showing various bugs\n")
cecho("<red>1Mudlet<green><<2>>Mudlet<blue>3Mudlet\n")
decho("<255,100,100>1Mudlet<255,2,3:0,200,0><<2>>Mudlet<1,1,200>3Mudlet\n")
hecho("|cff00bb,000,Mudlet0|abc,aabbccMudlet|c00ffbb,aabbcc2Mudlet|c00bbffbbaaff3Mudlet\n")
hecho("|cff00,000 documentation of hecho() needs to be changed to depend on double figure hex numbers\n")


Re: Unit testing for mudlet-lua

Posted: Fri Aug 02, 2013 8:03 am
by Heiko
Addendum:
If I remember correctly, the cecho/cinsert functions didn't work correctly when used in conjunction with mini consoles. Has this been fixed?

Re: Unit testing for mudlet-lua

Posted: Fri Aug 02, 2013 9:38 am
by Vadi
A long while ago, I think.

I haven't ran the test script yet.