Workflow: Running tests
There are several ways to run tests in the Test Runner window:
- Double-click on the test or test fixture name.
- Use the Run All or Run Selected buttons at the bottom of the window.
- Right-click on any item in the test tree and choose Run in the context menu to run the test and all of its children.
When you run a test the test status icon changes to show the result and a counter in the top right corner updates:
Filters
If you have a lot of tests, and you only want to view/run a sub-set of them, you can filter them in several ways (see image above):
Type in the search box in the top left
Click a test class or fixture (such as NewTestScript in the image above)
Click one of the test result icon buttons in the top right
Select or deselect the EditMode and PlayMode check boxes to include or exclude tests of that type.
Running tests from the command line
You can also run a test project from the Unity command line. Here is an example in Windows:
Unity.exe -runTests -batchmode -projectPath PATH_TO_YOUR_PROJECT -testResults C:\temp\results.xml -testPlatform PS4
Note: Use the
-batchmode
option when running tests on the command line to remove the need for manual user inputs. For more information, see Unity Command line arguments.
For the full list of Unity Test Framework command line arguments, see the command line reference.
Run tests within Rider
It is possible to run unit tests in the Unity Test Framework directly from JetBrains Rider.
For more information, see the JetBrains official documentation and their blog post Run Unity tests in Rider 2018.1.