diff --git a/MCPForUnity/Editor/Tools/RunTests.cs b/MCPForUnity/Editor/Tools/RunTests.cs index 9c7482949..710b8b2dd 100644 --- a/MCPForUnity/Editor/Tools/RunTests.cs +++ b/MCPForUnity/Editor/Tools/RunTests.cs @@ -87,14 +87,7 @@ public static async Task HandleCommand(JObject @params) var result = await runTask.ConfigureAwait(true); - string message = - $"{parsedMode.Value} tests completed: {result.Passed}/{result.Total} passed, {result.Failed} failed, {result.Skipped} skipped"; - - // Add warning when no tests matched the filter criteria - if (result.Total == 0) - { - message += " (No tests matched the specified filters)"; - } + string message = FormatTestResultMessage(parsedMode.Value.ToString(), result); var data = result.ToSerializable(parsedMode.Value.ToString(), includeDetails, includeFailedTests); return new SuccessResponse(message, data); @@ -127,6 +120,20 @@ private static TestFilterOptions ParseFilterOptions(JObject @params) }; } + internal static string FormatTestResultMessage(string mode, TestRunResult result) + { + string message = + $"{mode} tests completed: {result.Passed}/{result.Total} passed, {result.Failed} failed, {result.Skipped} skipped"; + + // Add warning when no tests matched the filter criteria + if (result.Total == 0) + { + message += " (No tests matched the specified filters)"; + } + + return message; + } + private static string[] ParseStringArray(JObject @params, string key) { var token = @params[key]; diff --git a/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/RunTestsTests.cs b/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/RunTestsTests.cs index a52caee72..28ecb5064 100644 --- a/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/RunTestsTests.cs +++ b/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/RunTestsTests.cs @@ -27,7 +27,7 @@ public void FormatResultMessage_WithNoTests_IncludesWarning() var result = new TestRunResult(summary, new TestRunTestResult[0]); // Act - string message = FormatTestResultMessage("EditMode", result); + string message = MCPForUnity.Editor.Tools.RunTests.FormatTestResultMessage("EditMode", result); // Assert - THIS IS THE NEW FEATURE Assert.IsTrue( @@ -51,7 +51,7 @@ public void FormatResultMessage_WithTests_NoWarning() var result = new TestRunResult(summary, new TestRunTestResult[0]); // Act - string message = FormatTestResultMessage("EditMode", result); + string message = MCPForUnity.Editor.Tools.RunTests.FormatTestResultMessage("EditMode", result); // Assert Assert.IsFalse( @@ -61,21 +61,6 @@ public void FormatResultMessage_WithTests_NoWarning() Assert.IsTrue(message.Contains("4/5 passed"), "Should contain pass ratio"); } - /// - /// Helper method to format test result message. - /// This matches the implementation in RunTests.cs. - /// - private static string FormatTestResultMessage(string mode, TestRunResult result) - { - string message = $"{mode} tests completed: {result.Passed}/{result.Total} passed, {result.Failed} failed, {result.Skipped} skipped"; - - // Add warning when no tests matched the filter criteria - if (result.Total == 0) - { - message += " (No tests matched the specified filters)"; - } - - return message; - } + // Use MCPForUnity.Editor.Tools.RunTests.FormatTestResultMessage directly. } }