Videos

How to Unit Test Unity Code

Unit testing Unity code can pretty challenging at first. But learning how to unit test your game code is a valuable skill that every game developer should have in their toolkit.

The Value of Unit Testing Unity Code

As game developers, we face many challenges in our day-to-day. Brainstorming interesting game mechanics, locating high quality art assets, and creating marketing strategies is hard enough when our code is working as expected.

But sometimes (often at the worst possible moment) a bug appears and demands our full attention. And what’s worse is how difficult game code can be to debug. For instance, have you ever had a physics bug manifest itself in the form of your gameObjects flying off of the screen? Where do you even begin with something like that?

While I’m not promising that you can prevent every bug, I do believe that having automated tests greatly decreases the amount of bugs that catch you off guard. They effectively decrease the amount of game breaking errors, never letting them near your players. And as an added bonus, automated tests increase your confidence in the game code so you can deal with the more pressing matters of game development.