Skip to main content
GameDev.net gamedev.net
🔒 Locked

TDD

Started by btownsen4 Jan 4, 2009 at 4:49 PM 4 replies 2k views
Original Post
btownsen4
btownsen4
Does anyone use TDD for their game development? (Test Driven Development) Just curious, and please share your experiences with TDD. I'm considering using TDD for my own development but don't understand how it works into the whole graphical model. MVC TDD maybe? [Edited by - btownsen4 on January 4, 2009 5:08:37 PM]
hymerman
hymerman
I'm using it for some things. I think trying to force all your development to use it would be foolish. Some parts of games are so hard to develop with TDD that you end up using more resources than you gain. But for maths libraries (perfect starting ground for TDD..), game object systems, file parsers and so on, I'm finding it a real joy to write tests and code.

I shan't list all the reasons it's good since that's not what you're asking :)
rogma
rogma
Going TDD will lead you to separate concerns and features. So going MVC seems a pretty good choice :
you will be able to test game object mechanics/physics/network... without the need of a display or other system and conversely

Event if TDD and MVC does not relate both theoretically nor generally, in the case of game programming I hardly see other choice (not meaning there is not).

Going component could help you too : it allow testing features one by one and separately.

I have gone both (MVC and component) and *almost* TDD (see code on projet-univers).
Testing game objects is quite easy (see for example the Laser test : we build a ship and fire then check that a new object representing the beam has appeared), physics is quite fun too.

I still have difficulties to test some areas (graphics and sound) : my best guess would be to perform queries on the Ogre3D structure built. Current graphics test are only segfault trackers.

That's what I have recently done for GUI with great benefits. A bit laborious at first but then working faster and faster.

Concerning the debate *investment versus gain of TDD* in an area as complex as game development, maybe it's a revival of "TDD is costly" ?
At first that what I thought, but my opinion is the following : sometimes I cannot see how to test a feature, or it seems to difficult at first sight and after I tried a few times it costs lesser and lesser.

Regards
frob
frob
Quote:
Does anyone use TDD for their game development? (Test Driven Development) Just curious, and please share your experiences with TDD.
I use it in games both at work and in homebrew, and have used it professionally outside of games.

My TDD experiences are given at several TDD-centric sites. The TDD mailing list yahoo group is a very active community and includes most big-name individuals, a few of them are in games. You'd be best by reading a few years of the mailing list before asking your questions, though. :)

The blog linked to earlier is good, and google can find more like it.


Quote:
I'm considering using TDD for my own development but don't understand how it works into the whole graphical model. MVC TDD maybe?

TDD and graphics is a common problem for beginners. You must keep in mind exactly what you are testing. A common mistake is to try to use TDD for the stuff on the screen. Don't forget that you are trying to test your own code, not your use of the drawing API.

TDD works very well for data-oriented features and state-based objects. It works very well for chunks of code that can be unit tested. It works well for chunks of code inside integration tests.

TDD works much less well for OS-heavy features. It is a common trap to end up testing the OS functions rather than your actual code. Not only does it test the wrong thing, but the tests generally run extremely slow rather than instantly.



What graphical model things are you trying to TDD? Perhaps we could discuss those specifically to help get you moving again.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.