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:

  1. Select Build Automation > Configurations.
  2. Select the edit (pencil) icon to open the build target settings.
  3. Select Advanced Settings.
  4. Under the Tests section, select the test options that you want to enable.
  5. 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 OptionDescription
Run my project's unit tests when buildingUnit tests run when you run a build.
Run EditMode testsYour Edit Mode tests run when you run a build.
Run PlayMode testsYour Play Mode tests run when you run a build.
Mark build as failed if any test failsUBA 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:

  1. Navigate to the Build History section in the Unity Cloud Dashboard.
  2. Select the completed build to view its details.
  3. Review the test summary to find the number of passed, failed, and skipped tests.
  4. Download detailed test reports for in-depth analysis.

UBA Unit Test View

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.