Repository navigation
Description
There seems to be anm issue with the UnityMCP - run_tests (MCP)(mode: "play") command.
Basically if I try have claude code run the test runner, the test runner throws exceptions. When I run the tests manually via the GUI, it works fine.
It's pretty important that this works for iteration purposes.
I sincerely apologise for this horrendous console dump:
UnityMCP - read_console (MCP)(action: "get", count: 50, format: "detailed")
⎿ {
"success": true,
"message": "Retrieved 9 log entries.",
"data": [
{
"type": "Log",
"message": "<color=#2EA3FF>MCP-FOR-UNITY: MCPForUnityBridge started on port 6400.
(OS=WindowsEditor, server=6.3.0)",
"file": "./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/Helpers/McpLog.cs",
"line": 20,
"stackTrace": "UnityEngine.Debug:Log (object)\nMCPForUnity.Editor.Helpers.McpLog:Info (string,bool) (at
./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/Helpers/McpLog.cs:20)\nMCPForUnity.Editor.MC
PForUnityBridge:Start () (at ./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/MCPForUnityBrid
ge.cs:395)\nMCPForUnity.Editor.MCPForUnityBridge:EnsureStartedOnEditorIdle () (at
./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/MCPForUnityBridge.cs:267)\nUnityEditor.Edito
rApplication:Internal_CallUpdateFunctions ()"
},
{
"type": "Log",
"message": "<color=#2EA3FF>MCP-FOR-UNITY: Auto-discovered 10 tools and 3 resources (13
total handlers)",
"file": "./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/Helpers/McpLog.cs",
"line": 20,
"stackTrace": "UnityEngine.Debug:Log (object)\nMCPForUnity.Editor.Helpers.McpLog:Info (string,bool) (at
./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/Helpers/McpLog.cs:20)\nMCPForUnity.Editor.To
ols.CommandRegistry:AutoDiscoverCommands () (at ./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Edi
tor/Tools/CommandRegistry.cs:101)\nMCPForUnity.Editor.Tools.CommandRegistry:Initialize () (at
./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/Tools/CommandRegistry.cs:50)\nMCPForUnity.Ed
itor.MCPForUnityBridge:Start () (at ./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/MCPForUn
ityBridge.cs:399)\nMCPForUnity.Editor.MCPForUnityBridge:EnsureStartedOnEditorIdle () (at
./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/MCPForUnityBridge.cs:267)\nUnityEditor.Edito
rApplication:Internal_CallUpdateFunctions ()"
},
{
"type": "Log",
"message": "<color=#2EA3FF>MCP-FOR-UNITY: No PythonToolsAsset found. Create one via Assets
> Create > MCP For Unity > Python Tools",
"file": "./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/Helpers/McpLog.cs",
"line": 20,
"stackTrace": "UnityEngine.Debug:Log (object)\nMCPForUnity.Editor.Helpers.McpLog:Info (string,bool) (at
./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/Helpers/McpLog.cs:20)\nMCPForUnity.Editor.Se
rvices.ToolSyncService:SyncProjectTools (string) (at ./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038b
e/Editor/Services/ToolSyncService.cs:32)\nMCPForUnity.Editor.Helpers.PythonToolSyncProcessor:SyncAllTools ()
(at ./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/Helpers/PythonToolSyncProcessor.cs:96)\n
MCPForUnity.Editor.Helpers.PythonToolSyncProcessor/<>c:<.cctor>b__2_0 () (at
./Library/PackageCache/com.coplaydev.unity-mcp@2ab49ec038be/Editor/Helpers/PythonToolSyncProcessor.cs:29)\nUnit
yEditor.EditorApplication:Internal_CallDelayFunctions ()"
},
{
"type": "Exception",
"message": "InvalidOperationException: This cannot be used during play mode.",
"file": "./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/TestRun/Task
s/Scene/SaveModifiedSceneTask.cs",
"line": 13,
"stackTrace": "UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo
(System.String message) (at <08b6666d108d4c9796450fb85df4d5b2>:0)\nUnityEditor.SceneManagement.EditorSceneManag
er.SaveCurrentModifiedScenesIfUserWantsTo () (at <08b6666d108d4c9796450fb85df4d5b2>:0)\nUnityEditor.TestTools.T
estRunner.TestRun.Tasks.Scene.SaveModifiedSceneTask+d__1.MoveNext () (at
./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/TestRun/Tasks/Scene/SaveMod
ifiedSceneTask.cs:13)\nUnityEditor.TestTools.TestRunner.TestRun.TestJobRunner.ExecuteStep () (at
./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/TestRun/TestJobRunner.cs:17
3)\nUnityEditor.EditorApplication:Internal_CallUpdateFunctions()"
},
{
"type": "Log",
"message": "An unexpected error happened while running tests.",
"file": "./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/Api/Callback
sDelegator.cs",
"line": 67,
"stackTrace": "UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()"
},
{
"type": "Log",
"message": "Too many instant steps in test execution mode: Error. Current task ExitPlayModeTask.",
"file":
"./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/TestRun/TestJobRunner.cs",
"line": 119,
"stackTrace": "UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()"
},
{
"type": "Exception",
"message": "Exception: Playmode tests were aborted because the player was stopped.",
"file": "./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/TestRun/Task
s/PlayModeRunTask.cs",
"line": 59,
"stackTrace": "UnityEditor.TestTools.TestRunner.TestRun.Tasks.PlayModeRunTask+d__1.MoveNext ()
(at ./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/TestRun/Tasks/PlayModeR
unTask.cs:59)\nUnityEditor.TestTools.TestRunner.TestRun.TestJobRunner.ExecuteStep () (at
./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/TestRun/TestJobRunner.cs:17
3)\nUnityEditor.EditorApplication:Internal_CallUpdateFunctions()"
},
{
"type": "Log",
"message": "An unexpected error happened while running tests.",
"file": "./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/Api/Callback
sDelegator.cs",
"line": 67,
"stackTrace": "UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()"
},
{
"type": "Warning",
"message": "Executing IPostBuildCleanup for: Unity.PerformanceTesting.Editor.TestRunBuilder.",
"file": "./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/TestRun/Task
s/BuildActionTaskBase.cs",
"line": 51,
"stackTrace": "UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()"
}
]
}
Activity
coderabbitai commentedon Nov 4, 2025
A summary of the changes CodeRabbit can apply:
msanatan commentedon Nov 5, 2025
@bazzboyy1 you can use markdown tags to help format the dump, like ``` (https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax)
Thanks for flagging! With the test runner I've mostly used it for editor mode tests, less so for Play mode. It looks like our AI helper might has some ideas but I'm not sure that's the actual fix.
Why do you have
SaveModifiedSceneTask.cs? That file is callingSaveCurrentModifiedScenesIfUserWantsTo(), which is not available in Play mode. It's an error with your code and setup.Instead of using that file, you can save the scene manually or instruct the LLM to do so before running tests
msanatan commentedon Nov 8, 2025
@bazzboyy1 let me know, I'll close by Monday. Logs indicate it's an error in your project
bazzboyy1 commentedon Nov 9, 2025
Hey so I'm not calling this from my code, it's from the Unity Test Runner. It's the one trying to save the scene. I've tried running this in an empty scene and I get the same result.
InvalidOperationException: This cannot be used during play mode. UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo (System.String message) (at <08b6666d108d4c9796450fb85df4d5b2>:0) UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo () (at <08b6666d108d4c9796450fb85df4d5b2>:0) UnityEditor.TestTools.TestRunner.TestRun.Tasks.Scene.SaveModifiedSceneTask+<Execute>d__1.MoveNext () (at ./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/TestRun/Tasks/Scene/SaveModifiedSceneTask.cs:13) UnityEditor.TestTools.TestRunner.TestRun.TestJobRunner.ExecuteStep () (at ./Library/PackageCache/com.unity.test-framework@5ac417e07314/UnityEditor.TestRunner/TestRun/TestJobRunner.cs:173) UnityEditor.EditorApplication:Internal_CallUpdateFunctions()Could this be a bug with the Unity API? I'm running Unity V6.0.4
msanatan commentedon Nov 10, 2025
Just to be clear, @bazzboyy1, is your scene saved before running the test?
bazzboyy1 commentedon Nov 11, 2025
yep @msanatan, I've tried running it in an empty scene too with the same result. Not an empty project though which I suppose I could try
FriedrichWessel commentedon Nov 11, 2025
I see the same issue.
From a quick scan: The most likely issue is the TestRunnerService:74
The TestRunnerAPI's internal task pipeline includes the
SaveModifiedSceneTaskas part of its scene setup/teardown process.This calls:
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()This is not available during Playmode - so most likely the timing here is off when running via TestRunner instead of running with the UI.
Since it also happens when the scene is not marked as dirty - saving the scene upfront wont help - but its maybe worth a try:
other option would be to try monkey-path with reflection ( pretty hacky - but could proof my theory )
That should at least tell us if thats the issue.
I will see if I find some time to test those in the next days - if no one else wants to pick it up before.
[-]Test Runner exceptions when the GUI does not.[/-][+]Test Runner fails in Play Mode[/+]msanatan commentedon Nov 26, 2025
Didn't mean to mark as completed, but it should be fixed in v8.0.1. Can someone else update and confirm?
@bazzboyy1 @FriedrichWessel @Redhaozzz @tribbloid