[crossfire] Unit tests (was: Code cleanlieness and server stability)

Alex Schultz alex_sch at telus.net
Mon Feb 27 18:29:04 CST 2006


I was reading up a little bit on unit tests, and I was thinking, that it 
might be an interesting idea to integrate some unit testing into the 
server. The difficulty is, it would be difficult to create tests that 
could work in a useful way with something as complex as the crossfire 
server, however I feel that it might be possibly to be able to create 
some sort of unit testing that may be of worth.
To test something like the crossfire server, an awful lot of tests would 
need to be implemented and it would take alot of planning.
Some possible unit tests could be:
-'Boulder' mechanics test:
Have a basic map with some of the 'boulder mechanics', as a test of 
various classic map elements like teleporters, buttons, check invs, 
gates, pits, and such things. Perhaps also have the testing 'script' 
test magic mouths and ears. This test may not the most useful for 
finding bugs, but some things like some edge-of-map scenarios could be 
included. It would also not involve much effort other than creating the 
map, and having the script test for certain end conditions.

-Spellcasting test:
This is in my opinion a more useful test for discovering crashes. The 
test would have a test map that would have a variety of conditions, 
including some monsters, edge-of-map situations, and teleporters. The 
test could teleport a fake player between almost every map square, and 
casts every spell on each square. This could if designed properly test 
many different conditions.

-Weather/Map loading test:
This test would rapidly load several bigworld maps into memory, and 
process the weather on them a few times each, swapping out from time to 
time, and verifying that no original map squares have been lost in 
memory. (This test may currently fail in some cases)

-Random map generator test:
This test would quickly generate and load many random maps with a mix of 
parameters, using ever combination of styles in the maps and varying 
other parameters like size and style.

And other tests could be done too of course, mostly limited by what one 
could think of.
The big question is, is this worth it? Well, in my opinion, it would 
take a significant amount of effort to make, and useful results might 
not be seen very often with it, however I feel that it might be good to 
have some sort of 'stress test' like this, pushing game conditions to 
their limits, and use that as yet another way to find some of the more 
subtle bugs as them occur. I think that if this is implemented as a 
plugin of some sort that can be optionally built, it wouldn't cutter the 
server code too much either. This said, I'm not sure its the greatest 
idea, but right now I'm brainstorming a bit and it does seem plausible 
anyways and might have some benefits.

Alex Schultz



More information about the crossfire mailing list