Skip to content

Commit 4dcebed

Browse files
committed
2 parents 73f2cc7 + 9651637 commit 4dcebed

File tree

6 files changed

+67
-7
lines changed

6 files changed

+67
-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)

README-ja.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,17 @@ MCP Unityサーバーをデバッグするには、以下の方法を使用で
244244
- メニュー項目が確認を必要とするかどうかを確認
245245
- メニュー項目が現在のコンテキストで利用可能であることを確認
246246

247+
#### Play Modeテスト実行時に `Connection failed` エラー
248+
249+
`run_tests` ツールの実行が次のエラーを返します:
250+
```
251+
Error:
252+
Connection failed: Unknown error
253+
```
254+
255+
このエラーは、Play Modeに切り替わる際にドメインがリロードされるため、ブリッジ接続が失われることで発生します。
256+
回避方法は、**Edit > Project Settings > Editor > "Enter Play Mode Settings"****Reload Domain** をオフにすることです。
257+
247258
## 貢献
248259

249260
貢献は大歓迎です!詳細については[貢献ガイド](CONTRIBUTING.md)をお読みください。

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,19 @@ Don't forget to shutdown the server with `Ctrl + C` before closing the terminal
327327
- Verify that the menu item is available in the current context
328328
</details>
329329

330+
<details>
331+
<summary><span style="font-size: 1.1em; font-weight: bold;">Connection failed when running Play Mode tests</span></summary>
332+
333+
The `run_tests` tool returns the following response:
334+
```
335+
Error:
336+
Connection failed: Unknown error
337+
```
338+
339+
This error occurs because the bridge connection is lost when the domain reloads upon switching to Play Mode.
340+
The workaround is to turn off **Reload Domain** in **Edit > Project Settings > Editor > "Enter Play Mode Settings"**.
341+
</details>
342+
330343
## Support & Feedback
331344

332345
If you have any questions or need support, please open an [issue](https://github.com/CoderGamester/mcp-unity/issues) on this repository.

README_zh-CN.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ MCP Unity 通过将 Unity `Library/PackedCache` 文件夹添加到您的工作
246246
- 检查菜单项是否需要确认
247247
- 验证菜单项在当前上下文中是否可用
248248

249+
#### 运行播放模式测试时连接失败
250+
251+
`run_tests` 工具返回以下响应:
252+
```
253+
Error:
254+
Connection failed: Unknown error
255+
```
256+
257+
发生此错误的原因是在切换到播放模式触发域重新加载时,桥接连接会丢失。
258+
解决方法是在 **Edit > Project Settings > Editor > "Enter Play Mode Settings"** 中关闭 **Reload Domain**
259+
249260
## 贡献
250261

251262
欢迎贡献!请阅读我们的[贡献指南](CONTRIBUTING.md)以获取更多信息。

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)