Skip to main content
Version: v3

Test

The Unity Orb provides the test job to facilitate the process of testing your Unity project.

At the end of the run, the test results are parsed to JUnit and stored in CircleCI so that test insights can be used. You can access test insights from the CircleCI web app.

Parameters​

Below you will find information on each parameter that can be passed to the test job.

executor​

The executor on which you want to run your test job on. Each executor has its set of parameters. See the Executors section for more details.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
test-unity-project:
jobs:
- unity/test:
executor:
name: 'unity/ubuntu'
target_platform: 'linux-il2cpp'
editor_version: '2021.3.2f1'
resource_class: 'medium'
  • Default: N/A
  • Required: True
  • Type: Executor

no_output_timeout​

Elapsed time without output before the job is canceled and stopped. The value can be in hours, minutes or seconds - a digit followed by h, m or s respectively. Consider increasing it if you see this error:

Too long with no output (exceeded 20m0s): context deadline exceeded

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
test-unity-project:
jobs:
- unity/test:
no_output_timeout: 30m
  • Default: 20m
  • Required: false
  • Type: string

project-path​

If your project sits at the root of your repository, leave it to the default value. Otherwise, enter the path of your Unity project. This should be the directory that has an "Assets" folder inside it.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
test-unity-project:
jobs:
- unity/test:
project-path: 'Unity2D-Demo-Game-CI-CD/src'
  • Default: .
  • Required: False
  • Type: String

return-license​

Whether to manually return the Unity license after the test job is finished. This is usually unnecessary and only useful when running into an unrecoverable error while having a license active. Additionally, Unity only allows returning professional licenses.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
test-unity-project:
jobs:
- unity/test:
return-license: true
  • Default: false
  • Required: false
  • Type: boolean

step-name​

Specify a custom step name to be shown in the CircleCI web app.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
test-unity-project:
jobs:
- unity/test:
step-name: 'Test my Unity project'
  • Default: Run tests
  • Required: False
  • Type: String

test-platform​

Choose the platform to run your tests on. The available options can be found on the Unity test framework documentation.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
test-unity-project:
jobs:
- unity/test:
test-platform: 'playmode'
  • Default: editmode
  • Required: False
  • Type: String

unity-license-var-name​

The name of the environment variable holding the license set in your Context. If you are testing your project using the Unity Pro or Plus license, this is not required. See Activation for more details.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
test-unity-project:
jobs:
- unity/test:
unity-license-var-name: 'UNITY_ENCODED_LICENSE'
  • Default: UNITY_ENCODED_LICENSE
  • Required: False
  • Type: env_var_name

unity-password-var-name​

The name of the environment variable holding the password set in your Context. See Activation for more details.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
test-unity-project:
jobs:
- unity/test:
unity-password-var-name: 'UNITY_PASSWORD'
  • Default: UNITY_PASSWORD
  • Required: False
  • Type: env_var_name

unity-serial-var-name​

The name of the environment variable holding the serial set in your Context. If you are testing your project using the Unity Personal license, this is not required. See Activation for more details.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
test-unity-project:
jobs:
- unity/test:
unity-serial-var-name: 'UNITY_SERIAL'
  • Default: UNITY_SERIAL
  • Required: False
  • Type: env_var_name

unity-username-var-name​

The name of the environment variable holding the username set in your Context. See Activation for more details.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
test-unity-project:
jobs:
- unity/test:
unity-username-var-name: 'UNITY_USERNAME'
  • Default: UNITY_USERNAME
  • Required: False
  • Type: env_var_name

Examples​

In this section, you will find examples of workflows using this job. However, notice that the separation used in the examples is only for the sake of visualisation. You can test all target platforms in the same workflow. All examples are based on CircleCI's Demo Project.

Personal License​

This example shows how to build your project for several platforms using a Personal License.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
build-unity-project:
jobs:
# Linux
- unity/test:
name: 'test-linux'
step-name: 'Check if the tests run and results are uploaded'
unity-license-var-name: 'UNITY_ENCODED_LICENSE'
unity-username-var-name: 'UNITY_USERNAME'
unity-password-var-name: 'UNITY_PASSWORD'
executor:
name: 'unity/ubuntu'
target_platform: 'linux-il2cpp'
editor_version: '2021.3.1f1'
resource_class: 'medium'
project-path: 'Unity2D-Demo-Game-CI-CD/src'
test-platform: 'playmode'
context: unity

# Windows
- unity/test:
name: 'test-windows'
step-name: 'Check if the tests run and results are uploaded'
unity-license-var-name: 'UNITY_ENCODED_LICENSE'
unity-username-var-name: 'UNITY_USERNAME'
unity-password-var-name: 'UNITY_PASSWORD'
executor:
name: 'unity/windows-2022'
size: 'large'
editor_version: '2021.3.2f1'
target_platform: 'windows-il2cpp'
project-path: 'Unity2D-Demo-Game-CI-CD/src'
test-platform: 'playmode'
context: unity

# macOS
- unity/test:
name: 'test-osx'
step-name: 'Check if the tests run and results are uploaded'
unity-license-var-name: 'UNITY_ENCODED_LICENSE'
unity-username-var-name: 'UNITY_USERNAME'
unity-password-var-name: 'UNITY_PASSWORD'
executor:
name: 'unity/macos'
editor_version: '2021.3.1f1'
resource_class: 'large'
project-path: 'Unity2D-Demo-Game-CI-CD/src'
test-platform: 'playmode'
context: unity

Professional License​

This example shows how to build your project for several platforms using a Pro License.

version: 2.1

orbs:
unity: game-ci/unity@x.y

workflows:
build-unity-project:
jobs:
# Linux
- unity/test:
name: 'test-linux'
step-name: 'Check if the tests run and results are uploaded'
unity-serial-var-name: 'UNITY_SERIAL'
unity-username-var-name: 'UNITY_USERNAME'
unity-password-var-name: 'UNITY_PASSWORD'
executor:
name: 'unity/ubuntu'
target_platform: 'linux-il2cpp'
editor_version: '2021.3.1f1'
resource_class: 'medium'
project-path: 'Unity2D-Demo-Game-CI-CD/src'
test-platform: 'playmode'
context: unity

# Windows
- unity/test:
name: 'test-windows'
step-name: 'Check if the tests run and results are uploaded'
unity-serial-var-name: 'UNITY_SERIAL'
unity-username-var-name: 'UNITY_USERNAME'
unity-password-var-name: 'UNITY_PASSWORD'
executor:
name: 'unity/windows-2022'
size: 'large'
editor_version: '2021.3.2f1'
target_platform: 'windows-il2cpp'
project-path: 'Unity2D-Demo-Game-CI-CD/src'
test-platform: 'playmode'
context: unity

# macOS
- unity/test:
name: 'test-osx'
step-name: 'Check if the tests run and results are uploaded'
unity-serial-var-name: 'UNITY_SERIAL'
unity-username-var-name: 'UNITY_USERNAME'
unity-password-var-name: 'UNITY_PASSWORD'
executor:
name: 'unity/macos'
editor_version: '2021.3.1f1'
resource_class: 'large'
project-path: 'Unity2D-Demo-Game-CI-CD/src'
test-platform: 'playmode'
context: unity