2.6 KiB
Welcome
Welcome to the Unity Test Framework general introduction course.
This course consists of different exercises to help you learn fundamental Unity Test Framework concepts through practical examples. Each exercise has a Learning Objectives section to help you identify the skills you will learn. The exercises are grouped thematically, and their difficulty varies.
After completing an exercise, you can check your solution against the one provided. Note that many of the exercises can be solved in several possible ways.
Import samples
Project files for each exercise and its accompanying solution are provided as samples with the Unity Test Framework package. To import an exercise or solution to your Unity Editor:
- Go to Window > Package Manager and, in the packages list view, selct Unity Test Framework.
- In the package details view, find the Samples section.
- Find the exercise or solution you want to import and click the import button.
Note: You can import an exercise and its solution or multiple exercises at the same time, but since several of the exercises use the same naming pattern this will likely result in compilation errors that prevent you running tests or building your project. The recommended workflow is to import and work on one exercise at a time. If you import additional exercises or solutions for reference, you can delete them again before running your main exercise.
Course outline
- Running a test in a Unity project
- Arrange, act, assert
- Semantic test assertion
- Custom comparison
- Asserting logs
- Setup and teardown
- Play mode tests
- Play mode tests in a player
- Using the UnityTest attribute
- Long-running tests
- Scene-based tests
- Setup and cleanup at build time
- Domain reload
- Preserve test state
- Test cases
- Custom attributes
- Running tests programmatically
Introduction to the Unity Test Framework (UTF)
Here you can find a video introduction to the Unity Test Framework.