Test Driven Design
2025/12/27
- Type
- Learning Resource
- Format
- Glossary Article
- Version
- General
- Subject Tags
- Created
- Updated
- 2026/02/16
- 2025/12/27
Test Driven Design or Test Driven Development (abbreviated as TDD) is when you write tests before you write code. It defines a formal specification and makes it easier to know what code to write.
These tests are called "unit tests" - they are micro testing functions that verify the smallest piece of code possible.
The TDD process typically follows these steps:
When all the tests pass, you're done. It's very satisfying, and in teams, very useful because everyone can use the code as soon as they know what it looks like, even if it doesn't exist yet. It also promotes the writing of isolated, independent pieces of code, so you can test them individually (that's why we call those "units").
If you have tests for most of your codebase, this is referred to as "code coverage." A "100% code coverage" means every piece of your code is tested. Of course that doesn't mean you don't have bugs. You could be writing useless tests, or the wrong tests. But TDD gives confidence and allows you to write with some level of certainty that the code will work as intended.
In games, TDD is not as useful as in general purpose software, because unit tests are difficult: in games, everything depends on everything else, so isolating a piece is not always easy or possible.
TDD might also lead to bloat, writing functionality and code that isn't necessary.
Instead, a similar, but potentially more useful pattern is used: Interface Driven Design. In IDD, you write code that uses a functionality before implementing it.
Don't stop here. Step-by-step tutorials are fun but they only take you so far.
Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.
Get help from peers and pros on GDQuest's Discord server!
20,000 membersJoin ServerThere are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!
Sponsor this library by learning gamedev with us onGDSchool
Learn MoreImprove and build on assets or suggest edits onGithub
Contributeshare this page and talk about GDQUest onRedditYoutubeTwitter…