Re: Unit tests

Noel Llopis <[email protected]> Fri, 15 Oct 2004 07:18:59 -0700
Newsgroups gmane.games.devel.general
Message-ID <[email protected]>
On Friday 15 October 2004 04:44 am, Chris Raine wrote:
> I found unit-testing cumbersome as soon as you come to debugging your
> unit-test code.

I don't understand how unit tests can be cumbersome to debug. A unit test 
should be extremely simple and be just a few lines long. You will hardly ever 
have to debug (as in, step in the debugger) a unit test itself. The problem 
should always be obvious it if fails because a unit test tests one and only 
one thing.

> As soon as you come to terms with more abstract and highlevel design
> aspects of your engine, the time and effort spent in unit-testing (for
> us at least) did not outweigh the benefits.

It sounds like you didn't have a good architecture. It's easier to start 
testing low-level features, but to test the high-level code, you really need 
a modular architecture with a minimum of dependencies.

The best way to arrive at this architecture is to use test-driven development 
(TDD). I can't recommend it highly enough. If you develop things that way, it 
will become immediately obvious how to structure your AI code so it's easily 
testable. You'll find you can create just about any object on the stack and 
manipulate it in isolation from other objects/libraries.

> For high level, abstact functionality we abandoned the unit test
> approach and implemented a nightly build script

Automated builds and unit tests are completely different things. You really 
should have both, not one or the other. Same thing with functional tests, 
which test whole game behaviors instead of small units of functionality. 
Ideally you would do all three.


--Noel
Games from Within
http://www.gamesfromwithin.com



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=557