Test Driven Development (TDD) in Unity for Indie Game Developers: Is it possible? Is it worth it?

The short answers are yes and no respectively. It’s possible, but not worth it for most indie developers.

Keep in mind that I am not talking about Unit Testing which has its place in any Unity project. What I’m talking about is adopting the philosophy of Test Driven Development (TDD) for the entire life cycle of developing a game.  This philosophy is just not worth the effort for Unity projects.

Three Reasons to not pursue TDD in Unity

In my day job, I primarily develop web applications in Ruby on Rails. Web applications (especially those written in Ruby on Rails) are unique in that an extensive infrastructure has been developed to enable TDD: unit test frameworks, integration test frameworks, test runners, continuous integration services and more. Also, what’s unique is that there is actually some consensus in the Ruby on Rails community on which tools to use.

  • Lack of tools for Unity: There is almost nothing like the Ruby on Rails TDD infrastructure for Unity. Take a look at this forum post: http://forum.unity3d.com/threads/8809-Test-Driven-Development. There is no consensus on even which unit testing framework to use. UUnit which is mentioned in the post seems to be abandoned and the documentation for what does exist is pretty sparse. 
  • The solution is pretty complex: In order to implement  TDD for Unity, you need to implement a Model-View-Controller (MVC) framework and Dependency Injection in your project. If you’ve never heard of Dependency Injection or even MVC before, that’s already a good reason to be concerned. This is a lot of programming background you require to get started with TDD.
  • ECall methods must be packaged into a system module: It seems to be impossible to create a Unity class in your test code. This isn’t really a problem for creating unit tests. The classes you design should interact with Unity game objects as little as possible. But when you adopt TDD, you need to be able to create Unity objects to test the code fully.


As an indie developer, you need to prototype your game quickly. Adopting TDD in Unity creates a ton of hurdles that you cannot afford to jump through. Pragmatically unit testing your code is a much better use of your time.

One Comment

Leave a Reply to Unit Testing in Unity: When is it useful for Indie Game Developers? | Game Development Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s