Re: [GD-General] Unit tests in a game engine
Brought to you by:
vexxed72
From: Noel L. <nl...@co...> - 2004-09-30 14:13:57
|
On Wednesday 29 September 2004 08:46 pm, Jason Bay wrote: > I'm very curious to explore how (or whether) the XP-stoked unit test > paradigm can work in games. I recommend you try asking in the sweng-gamedev mailing list. You're more likely to get many more answers there. Even looking through the archives, I think the topic has come up before (not for a while though). http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com > Are any of you are using automated unit tests > in your game engine? If so, do you have any suggestions to help me along? Yes, I'm a big fan of unit tests. A few years ago, I started writing unit tests after the implementation for some low-level subsystems, like math operations and such. It was somewhat useful, but I don't think the effort particularly paid off (especially not for a math library that never changed). About a couple of years ago, I started doing TDD (test-driven development: http://c2.com/cgi/wiki?TestDrivenDevelopment) for some low and mid level subsystems of the game engine. The difference was night and day. Not only did TDD create much better unit tests with much better coverage, but the most important thing is that it caused the design of the program itself to be different than what it would have been if I had started coding it first. Personally, I am totally sold on the idea of TDD. I'm convinced that the quality of a codebase is directly proportional to how easy it is to refactor. If you ever decide not to do something because of what it might break, then you're in trouble. Doing TDD is the easiest way to make sure you can continuously refactor your codebase. In the next few months we're going to roll out full TDD here at Sammy Studios, so it'll be interesting to see how it works out for a full game engine with the whole team on board. > Can you point me at any printed or online resources about unit testing that > would apply to real time games? There isn't much that is unique about games. Unit tests deal with small bits of functionality (single classes) in as much isolation as possible. For high-level functionality, you need to rely on existing tests for the low level code and just test the new functionality you're adding. If you designed things correctly, you should be able to test all you want almost in full isolation just by creating a few objects on the stack and interacting with them (if you find yourself creating new levels in the editor, then you're doing functional tests, not unit tests). If you haven't already, make sure you pick up the book "Test Driven Development" by Kent Beck, just so you're comfortable with the idea of mock objects and how to do TDD in general. At the beginning it might seem hard, but it soon becomes second nature if you keep at it. --Noel Games from Within http://www.gamesfromwithin.com |