Skip to content

Commit c6e6a6c

Browse files
Merge pull request #20 from nowsprinting/fix/run_tests_response
Fix `run_tests` response
2 parents 2d40387 + 613353d commit c6e6a6c

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

Editor/Tools/RunTestsTool.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ public void TestStarted(ITestAdaptor test)
114114
// Called when a test finishes
115115
public void TestFinished(ITestResultAdaptor result)
116116
{
117+
// Skip test suites (tests with children)
118+
if (result.Test.HasChildren)
119+
{
120+
return;
121+
}
122+
117123
_testResults.Add(new TestResult
118124
{
119125
Name = result.Test.Name,
@@ -136,8 +142,11 @@ public void RunFinished(ITestResultAdaptor result)
136142
// Create test results summary
137143
var summary = new JObject
138144
{
139-
["testCount"] = _testResults.Count,
140-
["passCount"] = _testResults.FindAll(r => r.Passed).Count,
145+
["testCount"] = result.PassCount + result.FailCount + result.SkipCount + result.InconclusiveCount,
146+
["passCount"] = result.PassCount,
147+
["failCount"] = result.FailCount,
148+
["skipCount"] = result.SkipCount,
149+
["inconclusiveCount"] = result.InconclusiveCount,
141150
["duration"] = result.Duration,
142151
["success"] = result.ResultState == "Passed",
143152
["status"] = "completed",
@@ -166,7 +175,13 @@ public void RunFinished(ITestResultAdaptor result)
166175
{
167176
["success"] = true,
168177
["type"] = "text",
169-
["message"] = summary["message"].Value<string>()
178+
["message"] = summary["message"].Value<string>(),
179+
["testCount"] = summary["testCount"],
180+
["passCount"] = summary["passCount"],
181+
["failCount"] = summary["failCount"],
182+
["skipCount"] = summary["skipCount"],
183+
["inconclusiveCount"] = summary["inconclusiveCount"],
184+
["results"] = summary["results"]
170185
});
171186
}
172187
catch (Exception ex)

Server/build/tools/runTestsTool.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ async function toolHandler(mcpUnity, params) {
5757
const testResults = response.results || [];
5858
const testCount = response.testCount || 0;
5959
const passCount = response.passCount || 0;
60+
const failCount = response.failCount || 0;
61+
const inconclusiveCount = response.inconclusiveCount || 0;
62+
const skipCount = response.skipCount || 0;
6063
// Format the result message
6164
let resultMessage = `${passCount}/${testCount} tests passed`;
6265
if (testCount > 0 && passCount < testCount) {
@@ -69,14 +72,16 @@ async function toolHandler(mcpUnity, params) {
6972
content: [
7073
{
7174
type: 'text',
72-
text: response.message || resultMessage
75+
text: resultMessage || response.message
7376
},
7477
{
7578
type: 'text',
7679
text: JSON.stringify({
7780
testCount,
7881
passCount,
79-
failCount: testCount - passCount,
82+
failCount,
83+
inconclusiveCount,
84+
skipCount,
8085
results: testResults
8186
}, null, 2)
8287
}

Server/src/tools/runTestsTool.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ async function toolHandler(mcpUnity: McpUnity, params: any): Promise<CallToolRes
7575
const testResults = response.results || [];
7676
const testCount = response.testCount || 0;
7777
const passCount = response.passCount || 0;
78+
const failCount = response.failCount || 0;
79+
const inconclusiveCount = response.inconclusiveCount || 0;
80+
const skipCount = response.skipCount || 0;
7881

7982
// Format the result message
8083
let resultMessage = `${passCount}/${testCount} tests passed`;
@@ -89,14 +92,16 @@ async function toolHandler(mcpUnity: McpUnity, params: any): Promise<CallToolRes
8992
content: [
9093
{
9194
type: 'text',
92-
text: response.message || resultMessage
95+
text: resultMessage || response.message
9396
},
9497
{
9598
type: 'text',
9699
text: JSON.stringify({
97100
testCount,
98101
passCount,
99-
failCount: testCount - passCount,
102+
failCount,
103+
inconclusiveCount,
104+
skipCount,
100105
results: testResults
101106
}, null, 2)
102107
}

0 commit comments

Comments
 (0)