Skip to content

Run editor tests in CI #107

@AlexSc

Description

@AlexSc

Summary

The new rake test task runs editor tests via Unity -executeMethod TeakTestRunner.RunAll. These tests are pure C# (no native SDKs needed) and complete in under 30 seconds once Unity opens. Currently they can only be run locally.

What's needed

The build job already runs on macOS (m4pro.medium with Xcode 14.3.1) but has no Unity installation. To run tests in CI we need:

  1. Unity installed on the macOS executor — via Unity Hub CLI or a pre-baked image
  2. Unity license credentialsUNITY_SERIAL, UNITY_EMAIL, UNITY_PASSWORD in a CircleCI context

Reference implementation

teak-unity-cleanroom already does this. Key patterns in its Rakefile:

  • Unity path discovery (line 40): UNITY_HOME env var with fallback to Dir.glob('/Applications/Unity/Hub/Editor/*').last
  • Unity helper method (lines 180–202): wraps invocations with -batchmode -nographics -quit -logFile and conditionally injects -serial/-username/-password when CI=true
  • License acquisition (line 286): unity_license:acquire task runs -executeMethod BuildPlayer.CheckLicense to activate the license before any other Unity work
  • License release (line 309): unity_license:release task returns the license after the build

The CI config (.circleci/config.yml lines 44–46) chains it as:

bundle exec rake unity_license:acquire ... $RAKE_BUILD_TASKS

with UNITY_HOME=/Applications/Unity-$UNITY_VERSION/.

Suggested approach

Add a test step to the build job (or a separate test job) that:

  1. Installs Unity on the executor (or uses a pre-baked image with Unity)
  2. Acquires a license (following cleanroom's pattern)
  3. Runs bundle exec rake test
  4. Releases the license

The test step should run before the package build since it validates C# compilation and logic with no native SDK dependency.


Repo: teak-unity

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions