This article serves as a high level overview of the tools rather than an in-depth drill-down. It covers the 3 components the package is comprised of:
- Unit tests
- Integration tests
- Assertion component
The package comes with detailed PDF documentation (in English and Japanese), examples and the complete source code so you can modifications in case they are needed.
There are many definitions to what a “unit test” is. In the context of this article it will be defined as a test that is:
- Written in code.
- Focuses on a single “thing” (method/class).
- Does not have “external dependencies” (e.g: does not rely on the Unity editor or needs to connect to an online service database).
Writing Unit Tests
To create unit tests, the package uses NUnit - a very popular framework that helps with the creation and execution of unit tests.
Also included is NSubstitute - a mocking framework that can create “fake” objects. These fakes are objects that are passed to the method under test instead of a “real” object, in cases where the “real” object can’t be created for testing since it relies on external resources (files, databases, remote servers, etc). For more information check out the NSubstitute site.
The following example shows a simple script that manages player health: