Testing Methodology

I was wondering if the experienced developers out there would mind sharing their thoughts on how they test their critters.  I'm currently planning on creating some test harness' so that I can write some nunit tests, but I can foresee some potential pitfalls related to code access security etc.  

What I'd like is:
1.  If you have some code out there already, I'd love to see it
2.  What things have given you grief regarding testing   
3.  What kinds of things would you like to be able to test, but currently can't.  

Thanks all.


Answer this question

Testing Methodology

  • lSalamon

    I've just come back to Terrarium after a long absence so apologies that this is so long after your original post.

    I used to use a 2 pronged testing approach when I was developing creatures.

    1. Write harnesses (and NUnit tests) with my own implementation of some of the Terrarium classes, e.g. OrganismState. This approach let me test all of my helper classes (e.g. navigation, pathfinding, memory, etc.) very effectively ouitside of the Terrarium. I did post some of this to the old Animal Farm and someone else (who's name I'm afraid I can't remember) developed it into a very nice test harness.

    2. Use very structured (i.e. programatically parseable) debugging output that I could capture in DbgView. This information included lots of data about my creature's state, what it could see, what it was doing etc. I would introduce my creature into a hostile terrarium (i.e. one the matches the live ecosystem as closely as possible) and capture ALL the output from ALL my ceratures until they all died. Didn't usually take too long :(  - I'd end up with a HUGE output file (like 50Mb+) . I then wrote a program that would parse this file and let me re-run each of my creatures lives one tick at a time to see what they did and why. I could also use the saved data from a single tick to recreate specific navigation situations when my creature tried to do something stupid.

    Worked well for me - but was an awful lot of work. It was also all pretty ropey old code for my own benefit so even assuming it all still works with v1.2 I'd be reluctant to share as it is.

    I'm not going to be near my dev machine for a few days, but when I've checked my creatures out against v1.2 I'll evaluate how much effort it would be to come up with something worth sharing.

    Cheers.

  • rajgz

    Ok, so I found the blog entry here:
    http://weblogs.asp.net/justin_rogers/archive/2004/03/29/100949.aspx

    Frankly this was somewhat unsatisfying, since it makes unit testing difficult outside of the actual game environment.  However I did see that there is a very rough calculation that might be made.  Since they want all of the animals to be processed every 300ms, you should be able to load up terrarium, check the number of animals you can support, and divide this number into 300ms.

    My plan is to incorporate the hi-res timer here:
    http://www.codeproject.com/csharp/highperformancetimercshar.asp

    to try and simulate a bug's tick

  • K.V.Bharath

    1.  I've often wanted a better testing mechanism than the "drop it in there an watch what happens" technique.  However, I never got around to building my own test platform (started briefly, but lost interest).  If you do implement something, please share!  I know there were some test platforms early on (posted in the old Animal Farm), but I'm pretty sure they were just for testing path finding (as that's the hardest thing to master).
    2.  Having to test with multiple bugs.  Putting a breakpoint in the code means you'll usually hit it for each bug.  When you hit the breakpoint, the only way to know if it's for the bug you want to*space
    space*on is to compare IDs.
    3.  I've always been able to manage.  You learn a few tricks along the way!

    Anyway, welcome and good luck!

    BTW, I read your other post and would be willing to team up my herbivore with a competant carnivore, if you are so inclined.

  • neobash

    Squish, feel free to contact me through my Blog contact form and I'll ask you some questions so I can provide a better posting about the Terrarium hosting code. The code is rather complex, and it isn't easy to simulate all of the hosting logic outside of the Terrarium itself. If you want to demonstrate all of the features, such as thread aborts, overages, etc... then you really do need to write a lot of code.

    That said, I have added some tick forward, tick backward UI controls for the source release that I'll be able to put out there in a couple of weeks I think. You can now host your creatures within Terrarium and tick through them one creature, tick, etc... at a time. These new controls aren't super functional, but I plan on merging an entire *creature debugger* into the application. This has been in the works for about a year now, and probably has another year to go before it is the end all creature tester unless I get some more time to work on it.

  • RobertoG

    Thanks for the feedback David.  

    Regarding testing:
    I’ll keep you up to date as I go.  I'll probably wind up writing test code as I require it, but I'll do what I can to make sure the test classes are generic.  Anyone else want to chime in with suggestions


    Regarding teaming:
    I’d definitely be interested in teaming up, but I won't be ready for awhile obviously.  I’ll keep you apprised of my progress.

    Incidentally, thank you for putting all of your code out in the farm.  You alone seem to be keeping the forum going.  I'll definitely be basing my pathing algorithms off of yours.  I have a few questions for you, but I think I'll post them in a different thread.

  • Pyramus

    Thanks for all the feedback guys.  I'll get back into this as soon as I can, but I'm trying to catch up w/ wedding planning right now, so it may be a few months. 

    Justin, how long before the source is released   That might give me a lot of what I need to do testing.

  • Winston Pang

    Ticks:
    Has anyone found a way to simulate ticks accurately   I have no idea how many instructions can be handled with each tick, but I'd like to restrict my organism to the same amount of time to think as it will in the wild.

  • Testing Methodology