• Jamie Guillemette

Unit Testing In Games - Intro

Updated: Oct 1, 2019

In my day job, I'm an advocate for Test-Driven Development. If you are not familiar with TDD development it is a process where developers write code that tests the business rules and functionality of their applications code. They frequently write these test before even implementing the logic so that they can prove the test goes from a fail status to pass status.

This has multiple benefits. First, on large projects, there is almost always an element of turn over. So having the code self verify that everything is working as intended when new members start making changes is super beneficial. But what if you are the only developer on a project? Why go through this effort then?

I order to be able to write a unit test, the developer must first be able to isolate a piece of logic and then pass to it different values and evaluate the outcome. This means the code can not be tightly coupled to the rest of the application. This means following good S.O.L.I.D. design principles.

Test-Driven Development helps developers write better code!

When a developer goes to implement the unit test, if they are unable to isolate the logic they need to test then that's an early warning sign that something needs to be refactored and decoupled.

TDD development is fairly popular in business programming but is relatively rare in game development. Perhaps this explains some of the grossly inexcusable bugs that have been included in many release titles over the past few years by triple-A developers.

As indie developers, we need to do better! We can not afford to burn our customers with sloppy unfinished products.

If you have made it this far, hopefully, you are on board that unit tests are a good thing. So how do you implement them in Unity?

My next series of blog posts will walk step by step on how to set up unit tests in Unity 2019.x

It will also show how to implement the Humble Object pattern to separate your core logic outside of Monobehaviours so that they can be tested outside both inside and outside play mode.

7 views0 comments

Recent Posts

See All