Run tests from the command line
Invoke-UnityTests.ps1 runs a Unity project's tests from
PowerShell on Windows and prints only what needs your attention: the tests that didn't pass, with
their messages, and a count of the rest. It's a generic script, independent of the kit: copy it
into any Unity project to use it there, whether or not that project has the kit.
Steps
-
Get the script:
Scripts~/Invoke-UnityTests.ps1in the kit's repository. If you installed the kit through the Creator Companion, it's also inPackages/com.tsvrc.udon-test-kit/Scripts~. A.unitypackagecan't carry it. -
Copy it into your project, such as its root folder. It finds the project by looking up from its own folder.
-
Close the Unity Editor. Batch mode can't open a project another Editor has open.
-
Run it from that folder:
.\Invoke-UnityTests.ps1
It runs your project's Edit Mode tests, then its Play Mode tests, each in its own batch-mode Unity process, and exits with 1 when a test failed or was inconclusive, or a run didn't finish. That makes it usable as a build step as it is.
Run part of the tests
Run one mode:
.\Invoke-UnityTests.ps1 -TestMode PlayMode
Run particular test assemblies, separated with ;:
.\Invoke-UnityTests.ps1 -AssemblyNames "MyWorld.Tests.EditMode;MyWorld.Tests.PlayMode"
By default, the script runs the tests in every assembly definition under Assets and in scripts
without one, and leaves out the tests that come with packages. The
reference page lists every option, including where it looks for
Unity and where it writes results.
If PowerShell refuses to run the script because of its execution policy, allow local scripts once
with Set-ExecutionPolicy -Scope CurrentUser RemoteSigned.