Showing the Unity Test Runner

This is a series of articles that will talk about Unit Test and Unity Test Runner.

For this Article, I will show Unity Test Runner.

How to enable Unit Test Runner

For to open Unit Test Runner, you can make it this way:

Window > General > Test Runner

After the window of the test, the unity will show the test runner.

The Unit Tests with unity can be made in PlayMode and EditMode

According to Unity Documentation

The Play Mode: You can run Play Mode tests as a standalone in a player or inside the Editor. Play Mode tests allow you to exercise your game code, as the tests run as coroutines if marked with the UnityTest attribute.

The Edit Mode: tests (also known as Editor tests) are only run in the Unity Editor and have access to the Editor code in addition to the game code.
With Edit Mode tests it is possible to test any of your Editor extensions using the UnityTest attribute. “

You can see more info about this in the official documentation here: https://docs.unity3d.com/Packages/com.unity.test-framework@1.1/manual/edit-mode-vs-play-mode-tests.html

For this article, I only will show it with PlayMode.

So let’s go to create the Test Folder, and select the option Create PlayMode Test Assembly Folder.

Now, you can see that Unity created a folder named Tests in your project.

If you open the folder, you will see that exists a Unity assembly (Don’t worry the Unity’s documentation has an explanation for this, and you will see it below).

What is Assembly?

According to Unity Documentation, An assembly is a C# code library that contains the compiled classes and structs that are defined by your scripts and which also define references to other assemblies.

If you want to learn more about Assemblies you can see the official documentation here: https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html#create-test-assembly

Now select the option Create Test Script In Current Folder.

Repair that in your folder a script has been created.

Now see that in your Test Runner Window, new content has been showing, this is the test methods written by Unity when our test script is created, I will talk more about this in the next article don’t worry.

So for this article, in the next article, I will open the test script, and I will talk about how to write unit tests, and which test framework we can use for this.

Follow me on Instagram to stay known when I create new posts.

You can also leave your feedback, and suggestion, I will read them all, and I will answer for you.

Thanks for reading.