Unit testing for mudlet-lua

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Unit testing for mudlet-lua

Post 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.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Unit testing for mudlet-lua

Post 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.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Unit testing for mudlet-lua

Post 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.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Unit testing for mudlet-lua

Post 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.

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Unit testing for mudlet-lua

Post by demonnic »

Though, as a quick note, it's generally considered bad form to commit code which breaks the tests in a project.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Unit testing for mudlet-lua

Post 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.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Unit testing for mudlet-lua

Post 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.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Unit testing for mudlet-lua

Post 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")


User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Unit testing for mudlet-lua

Post 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?

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Unit testing for mudlet-lua

Post by Vadi »

A long while ago, I think.

I haven't ran the test script yet.

Post Reply