Requirements

Understudy has the following requirements:

  • Unity 6.0 or later.
  • The Test Framework package (com.unity.test-framework), which Unity installs in new projects.
  • The Mono Cecil package (com.unity.nuget.mono-cecil) 1.10 or later. Understudy's compilation step uses it to rewrite the code under test. Importing Understudy installs it if your project doesn't have it.

Spies, stubs and fakes work in tests the Editor runs, and in Play mode tests the Test Runner builds into a player. The game you release is unchanged: a player build without tests is never woven and contains none of Understudy. For more information, refer to Player builds.

The Input System package (com.unity.inputsystem) is optional. When it is installed, leak detection also covers its devices and sensors. For more information, refer to Members Understudy declares non-deterministic.

Note: Understudy and Concordance, another Juste Tools package, aren't supported in the same project. For more information, refer to Concordance is not supported in the same project.

Install the package

To install Understudy, perform the following steps:

  1. Go to Window > Package Manager.
  2. Select My Assets, then select Understudy.
  3. If the package isn't downloaded yet, select Download.
  4. Select Import.
  5. In the Import Unity Package window, select Import.

When the import finishes and your scripts recompile, Understudy is active.

If the Console window shows an error that starts with Understudy: nothing is woven and names the Mono Cecil package, the package is missing or older than 1.10, for example because it was cleared in the Import Unity Package window. To install or update it, perform the following steps:

  1. Go to Window > Package Manager.
  2. Select + > Install package by name.
  3. Enter com.unity.nuget.mono-cecil, then select Install.

Update Understudy

To update Understudy to a new version, perform the following steps:

  1. Delete the Assets/Understudy folder, so that no file the new version removed stays behind.
  2. Import the new version, as in Install the package.

Between the two steps, the Console window shows compile errors for the tests that use Understudy. They clear once the import finishes.

Your settings are in ProjectSettings/Understudy.json, outside the package folder, so they stay as they are.

Remove Understudy

To remove Understudy from your project, perform the following steps:

  1. Delete the tests that use Understudy, or remove Understudy from the Assembly Definition References of their test assemblies and delete the code that uses it.
  2. Delete the Assets/Understudy folder. Unity recompiles every script, without weaving.
  3. Optionally, delete ProjectSettings/Understudy.json.

The Mono Cecil package stays installed, since other packages can depend on it.

Understudy menus

Understudy adds the following menu items to the Unity Editor:

The Tools > Understudy menu, with Settings, Quick Usage Guide, User Manual and Public API
Menu itemDescription
Tools > Understudy > SettingsOpens the Understudy page of the Project Settings window. For more information, refer to Project Settings reference.
Tools > Understudy > Quick Usage GuideOpens the Quick Usage Guide.
Tools > Understudy > User ManualOpens the User Manual.
Tools > Understudy > Public APIOpens the Public API reference.

Package contents

Understudy installs into Assets/Understudy as C# source, so it is committed with your project. The folder contains the following:

FolderContents
RuntimeSpies, stubs, fakes and leak detection, and the code analysis that checks your tests as you write them.
Runtime/Input SystemThe Input System members leak detection covers. Compiles only when the Input System package is installed.
CodeGenThe compilation step that rewrites the code under test in the Editor.
EditorThe Understudy page of the Project Settings window, and the checks that guard player builds.
TestsUnderstudy's own tests, which don't compile in your project.
DocumentationThe Quick Usage Guide, the User Manual, and the Public API reference.