Unity Test Runner Not Executing - Automated Testing Fix (How to Fix)
Problem Statement
The Unity Test Runner does not execute your tests: clicking Run All or Run Selected does nothing, or tests start but never complete. The Test Runner window may show no tests, tests stuck in a running state, or "Run All" finishes with no results. This blocks automated testing, CI pipelines, and regression checks.
Common symptoms:
- Run All or Run Selected has no effect; no tests run
- Test Runner window is empty or does not list your test methods
- Play Mode tests hang on "Legacy Play Mode Run" or similar and never finish
- Edit Mode tests run in code (e.g. Debug.Log appears) but the runner does not report pass/fail
- Tests passed before and stopped working after a Unity upgrade, package update, or project change
Root Cause Explanation
The Test Runner depends on several pieces working together:
- Test Framework package – Must be installed and compatible with your Unity version. Outdated or incompatible versions can prevent tests from executing or completing.
- Assembly definitions – Test assemblies must reference the assemblies under test and the test framework. Missing or incorrect references cause tests to be excluded or fail to compile in the test context.
- Compilation errors – Any script error in the project can prevent the test assemblies from compiling, so the Test Runner has nothing to run.
- Domain reload and Play Mode – Play Mode tests run in a separate domain; if domain reload is disabled or the run gets stuck, tests may never complete.
- Test attribute and namespace – Tests must use
[Test],[UnityTest], etc., and live in an assembly that the Test Runner discovers (usually one that references the Test Framework).
This guide walks you through checks and fixes so your automated tests run reliably.
Quick Fixes (Try These First)
1. Open the Test Runner and Confirm Tests Are Listed
If the Test Runner window is closed or tests are not discovered, you will see no execution.
Steps:
- Open Window → General → Test Runner (or Window → Analysis → Test Runner in some Unity versions).
- Ensure the EditMode or PlayMode tab is selected and that your test assembly is included (e.g. check Enable play mode tests for this assembly for PlayMode).
- Wait for Unity to compile. After compilation, the left panel should list your test methods.
- Click Run All or select a test and click Run Selected.
Verification: You should see test names in the list. If the list is empty, the Test Runner is not discovering your tests; continue to the next steps.
If tests still do not run: Proceed to step 2.
2. Install or Update the Test Framework Package
An missing, outdated, or incompatible Test Framework package is a common cause of tests not executing or not completing.
Steps:
- Open Window → Package Manager.
- Switch the dropdown to Unity Registry (or Packages: Unity).
- Search for Test Framework (com.unity.test-framework).
- If it is not installed, click Install. If it is installed, check for an Update and install the latest compatible version (e.g. 1.3.x or 2.x depending on your Unity version).
- Wait for the package to finish installing and for the project to recompile.
- Reopen the Test Runner and run your tests again.
Verification: After updating, run a single simple test (e.g. a minimal [Test] that passes). If it runs and reports Pass, the framework is working.
Reference: Unity Test Framework documentation.
If this doesn't work: Continue to the next step.
3. Fix All Script Compilation Errors
The Test Runner only runs tests from assemblies that compile successfully. A single compile error in the project or in a referenced assembly can prevent test discovery or execution.
Steps:
- Open Window → General → Console (or Ctrl+Shift+C).
- Fix every red error in the project. Do not rely only on warnings.
- Wait until the editor status shows compilation complete (no spinning icon).
- Reopen the Test Runner and run tests again.
Verification: With zero compilation errors, the test assembly should compile. If your tests live in an assembly that references other assemblies, ensure those referenced assemblies also compile. See Unity C# Compilation Errors - How to Fix for more detail.
4. Check Test Assembly Definition References
If your tests live in an assembly definition (.asmdef), that assembly must reference both the code under test and the Test Framework. Otherwise tests may not be discovered or may fail to run.
Steps:
- In the Project window, locate the assembly definition that contains your test scripts (e.g.
MyGame.Tests.asmdef). - Select it and in the Inspector check Assembly References.
- Ensure these are included:
- UnityEngine.TestRunner and UnityEditor.TestRunner (for Edit Mode and Test Runner infrastructure).
- **com.unity.modules.* or the specific assemblies your tests use (e.g. UnityEngine, UnityEngine.CoreModule**).
- The assembly or assemblies that contain the code you are testing (so your test code can reference those types).
- If you use Play Mode tests, ensure Enable play mode tests for this assembly is checked in the Test Runner window for that assembly, or that the asmdef has the appropriate references and the tests are in a valid assembly.
- Apply changes and let Unity recompile.
Verification: After recompile, the Test Runner should list your tests. Run a single test to confirm execution.
If tests are still not executing: Continue to the next step.
5. Resolve Play Mode Tests Stuck or Not Completing
Play Mode tests run in a separate play mode session. If they hang or never complete, try the following.
Steps:
- Check the Console – Look for unhandled exceptions or errors during the test run. Fix any errors that appear when tests start.
- Disable domain reload (optional) – In Edit → Project Settings → Editor, under Enter Play Mode Options, you can disable Domain Reload for faster iteration, but if your tests rely on a fresh domain, re-enable it and run again.
- Reimport test assets – In the Project window, right-click the folder containing your test scripts and choose Reimport. Then run the tests again.
- Reimport All (last resort) – Assets → Reimport All can resolve stuck or corrupted test state. This may take a long time on large projects.
Verification: Run a single Play Mode test (e.g. a [UnityTest] that yields one frame). It should start, run, and report Pass or Fail. If it still hangs, check for infinite loops or code that never returns in the test or in code executed during the test.
6. Ensure Test Methods Use the Correct Attributes
Unity only discovers methods marked with the correct attributes and in assemblies that reference the Test Framework.
Steps:
- Edit Mode tests: use
[Test]fromNUnit.Framework(e.g.using NUnit.Framework;). - Play Mode tests: use
[UnityTest](fromUnityEngine.TestTools) for IEnumerator tests that run over multiple frames. - Ensure the test class is
publicand the test method ispublicand returnsvoid(for[Test]) orIEnumerator(for[UnityTest]). - Example:
- Edit Mode:
[Test] public void MyTest() { Assert.Pass(); } - Play Mode:
[UnityTest] public IEnumerator MyUnityTest() { yield return null; Assert.Pass(); }
- Edit Mode:
Verification: After fixing attributes and signatures, the Test Runner should list the methods. Run one to confirm.
Alternative Fixes (Edge Cases)
- Tests pass individually but fail when run together – Often caused by shared state or static state between tests. Isolate state per test, use
[SetUp]/[TearDown], and avoid static variables that persist across tests. - Test Runner window missing or grayed out – Restart Unity and reopen the window. If the Test Framework package was just installed, wait for compilation and try again.
- CI or command-line test run fails – Use the same checklist above (packages, asmdef references, compilation). Ensure your CI uses a Unity version and modules that include the Test Framework. Run tests from the command line with the same Unity version you use in the editor to reproduce.
Prevention Tips
- Keep the Test Framework package updated to a version compatible with your Unity release.
- Use assembly definitions for test code and keep references to the Test Framework and to the code under test explicit.
- Run the Test Runner regularly so compilation and reference issues are caught early.
- Avoid relying on global or static state in tests; keep tests independent so "Run All" is reliable.
Related Problems and Links
- Unity Console Errors Not Showing – If you cannot see errors that block compilation, fix the console first: Unity Console Window Not Showing Errors - Debug Console Fix.
- Unity C# Compilation Errors – Fix script errors so test assemblies can compile: Unity C# Compilation Errors - How to Fix.
- Unity Build Fails with Missing Assembly References – Similar asmdef/reference issues can affect builds: Unity 2026.3 LTS Build Fails with Missing Assembly References.
- Official docs: Unity Test Framework - Running tests.
Bookmark this fix for quick reference when the Test Runner stops executing. If you are still stuck, check our Unity scripting and debugging guides for more on project setup and assembly structure. Share this article with your dev friends if it helped.