-
Notifications
You must be signed in to change notification settings - Fork 694
Feature/run tests summary clean #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ca03f7c
Optimize run_tests to return summary by default, reducing token usage…
dsarno 9e0d410
Add warning when run_tests filters match no tests; fix test organization
dsarno 372c74b
Refactor test result message formatting
dsarno 24f5eb2
Simplify RunTests warning assertions
dsarno 4b94751
Tests: de-flake cold-start EditMode runs
dsarno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/RunTestsTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| using System; | ||
| using Newtonsoft.Json.Linq; | ||
| using NUnit.Framework; | ||
| using MCPForUnity.Editor.Services; | ||
|
|
||
| namespace MCPForUnityTests.Editor.Tools | ||
| { | ||
| /// <summary> | ||
| /// Tests for RunTests tool functionality. | ||
| /// Note: We cannot easily test the full HandleCommand because it would create | ||
| /// recursive test runner calls. Instead, we test the message formatting logic. | ||
| /// </summary> | ||
| public class RunTestsTests | ||
| { | ||
| [Test] | ||
| public void FormatResultMessage_WithNoTests_IncludesWarning() | ||
| { | ||
| // Arrange | ||
| var summary = new TestRunSummary( | ||
| total: 0, | ||
| passed: 0, | ||
| failed: 0, | ||
| skipped: 0, | ||
| durationSeconds: 0.0, | ||
| resultState: "Passed" | ||
| ); | ||
| var result = new TestRunResult(summary, new TestRunTestResult[0]); | ||
|
|
||
| // Act | ||
| string message = MCPForUnity.Editor.Tools.RunTests.FormatTestResultMessage("EditMode", result); | ||
|
|
||
| // Assert - THIS IS THE NEW FEATURE | ||
| Assert.IsTrue( | ||
| message.Contains("No tests matched"), | ||
| $"Expected warning when total=0, but got: '{message}'" | ||
| ); | ||
| } | ||
|
|
||
| [Test] | ||
| public void FormatResultMessage_WithTests_NoWarning() | ||
| { | ||
| // Arrange | ||
| var summary = new TestRunSummary( | ||
| total: 5, | ||
| passed: 4, | ||
| failed: 1, | ||
| skipped: 0, | ||
| durationSeconds: 1.5, | ||
| resultState: "Failed" | ||
| ); | ||
| var result = new TestRunResult(summary, new TestRunTestResult[0]); | ||
|
|
||
| // Act | ||
| string message = MCPForUnity.Editor.Tools.RunTests.FormatTestResultMessage("EditMode", result); | ||
|
|
||
| // Assert | ||
| Assert.IsFalse( | ||
| message.Contains("No tests matched"), | ||
| $"Should not have warning when tests exist, but got: '{message}'" | ||
| ); | ||
| Assert.IsTrue(message.Contains("4/5 passed"), "Should contain pass ratio"); | ||
| } | ||
|
|
||
| // Use MCPForUnity.Editor.Tools.RunTests.FormatTestResultMessage directly. | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/RunTestsTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Add server-side tests to verify wiring of
include_failed_tests/include_detailsinto the Unity command params.The Python
run_testsentrypoint now exposes these flags and forwards them asincludeFailedTests/includeDetailsparams. Please add tests (e.g., using a mockedsend_with_unity_instance) that:run_testswith default args and assert neither key appears inparams.run_tests(include_failed_tests=True)and assert onlyincludeFailedTestsis present andTrue.run_tests(include_details=True)and assert onlyincludeDetailsis present andTrue.Truetogether to document combined behavior.This will lock in the client/server contract for test-result verbosity as the feature evolves.
Suggested implementation:
I assumed a pytest-based test suite and a module path
Server/tests/services/tools/test_run_tests.py. If your tests live elsewhere (e.g.,tests/server/services/tools/test_run_tests.pyor similar), adjust thefile_pathand the import/monkeypatch targets accordingly so that:from Server.src.services.tools.run_tests import run_testsmatches your actual import path.monkeypatch.setattrtargets forsend_with_unity_instanceandget_unity_instance_from_contextuse the correct fully-qualified module name.If your async test runner differs (e.g.,
pytest.mark.anyioor a custom helper), swap@pytest.mark.asynciofor the appropriate decorator.