Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions MCPForUnity/Editor/Tools/RunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,7 @@ public static async Task<object> 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);
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -61,21 +61,6 @@ public void FormatResultMessage_WithTests_NoWarning()
Assert.IsTrue(message.Contains("4/5 passed"), "Should contain pass ratio");
}

/// <summary>
/// Helper method to format test result message.
/// This matches the implementation in RunTests.cs.
/// </summary>
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.
}
}