[crossfire] Unit tests

Mark Wedel mwedel at sonic.net
Tue Feb 28 00:59:28 CST 2006


  I think this is a very good idea, and I do think a plugin is the way to go.

  In the past, I have made up some simplistic test maps to test broken things in 
a controlled environment - it also makes it easier to very that it is now 
working correctly.

  However, I certainly don't go back and re-run those tests manually.  Having a 
plugin do it wouldn't necessarily be hard.

  The plugin would I imagine read some form of command file, which could be 
something like:

load_map ...
activate_trigger x1,y1
sleep 10 (this in game ticks or something)
check_for_object x2,y2 boulder

  As a basic test to make sure a trigger activating spikes moves the boulder.

  I think a plugin is necessary because whatever is running the tests needs some 
way to look at the internal structures - what is on x2,y2.  Other commands I see 
would be inserting/removing items (to check handling of altars, buttons, etc)

  Such a plugin could actually handle a fair number of tests you describe.  IF 
there is a way for the plugin to be called every tick (as a global event), this 
can even cover things like spellcasting (the script could check for the presence 
of the spell on any number of spaces to confirm correct behavior).

  I do not envision running these unit tests on a server with players.  So if 
this plugin means it now takes 5 seconds for a tick to complete (say for complex 
spell tests where it is looking at a lot of spaces), that wouldn't be a big deal.

  Ideally, this test mode should be able to be started from command line, eg, 
crossfire -testscript ....

  which automatically loads the test plugin and runs it with testscript.

  I say this because some method of having this happen easily is highly 
desirable.  If I can do something like 'make tests', even if those tests take an 
hour, I could fire it off before I go to bed or something.  If I have to do 
special stuff to run the tests, this goes back to the test maps, nice to have, 
but doesn't do much good if never used.





More information about the crossfire mailing list