Unit tests
Enable unit tests in your Build Target configuration to catch issues early, ensure code quality, and prevent regressions before deployment. Unity Build Automation (UBA) provides integrated support to run unit tests as part of the build process. UBA supports both Edit Mode and Play Mode tests, with options to control test execution and handle failures.
Refer to more information on Edit Mode and Play Mode tests in the Unity Editor manual.
Enable unit tests
Enable and configure unit tests in the Unity Cloud Dashboard:
- Select Build Automation > Configurations.
- Select the edit (pencil) icon to open the build target settings.
- Select Advanced Settings.
- Under the Tests section, select the test options that you want to enable.
- Select Save changes.
If you encounter issues when you enable tests, ensure that you correctly set up your project's test assemblies and that you placed your scripts in appropriate directories, for example, Assets/Tests
. Use the Unity Editor's Test Runner to verify that tests are detected before you run builds in UBA.
Test configuration options
The following test options are available:
Test Configuration Option | Description |
---|---|
Run my project's unit tests when building | Unit tests run when you run a build. |
Run EditMode tests | Your Edit Mode tests run when you run a build. |
Run PlayMode tests | Your Play Mode tests run when you run a build. |
Mark build as failed if any test fails | UBA marks any build that fails a unit test suite as failed, even if the build is otherwise successful. |
Access and review test results
UBA provides test results in the build logs and artifacts. After a build completes:
- Navigate to the Build History section in the Unity Cloud Dashboard.
- Select the completed build to view its details.
- Review the test summary to find the number of passed, failed, and skipped tests.
- Download detailed test reports for in-depth analysis.
If results are missing or incomplete, check the following solutions:
- Check the Build logs for warnings or errors related to test execution.
- Check that you properly tagged and located your tests in recognized test folders.
Note: If a test unexpectedly fails, review recent code changes and confirm that you correctly configured all dependencies, such as scenes or assets.