Skip to content

Conversation

@dsarno
Copy link
Collaborator

@dsarno dsarno commented Jan 12, 2026

Removes placeholder tests, consolidates duplicates, and fixes tests with stale comments.

Changes

Python (-502 lines)

  • Delete 3 vestigial placeholder files
  • Remove empty skip-marked tests
  • Consolidate shared test helpers into test_helpers.py
  • Fix flaky timing threshold

C# (-154 lines)

  • Consolidate MCPToolParameterTests.cs from 755 → 361 lines (7 redundant tests removed)
  • Fix 3 "future feature" tests that were testing already-implemented features (auto-grow arrays, path normalization, bulk array mapping) - added proper assertions
  • Strengthen assertions in ManageGameObjectTests.cs and CommandRegistryTests.cs

Results

  • Python: 107 passed, 2 skipped ✅
  • Unity: 258 passed, 4 skipped ✅

Summary by Sourcery

Clean up and harden Unity and Python integration tests by removing vestigial cases, consolidating helpers, and strengthening behavioral assertions.

Bug Fixes:

  • Update telemetry queue timing threshold to avoid flaky performance assertions under variable CI load.
  • Correct ManageScriptableObject stress tests to assert current auto-grow arrays, friendly path normalization, and bulk array mapping behavior instead of treating them as future features.
  • Strengthen Unity command handler tests to verify error responses and callable handlers rather than only non-throwing behavior.

Enhancements:

  • Consolidate MCP tool parameter tests into focused end-to-end coverage for JSON parsing, material/property handling, and component property assignment.
  • Replace placeholder or speculative Unity tests with concrete assertions that validate real engine and tooling behavior.
  • Improve test helper utilities to support script-tool registration and reuse across multiple integration suites.

Tests:

  • Deduplicate and centralize Python integration test helpers for script-related tools via DummyMCP and setup_script_tools.
  • Remove empty or placeholder Python tests for transport framing, logging, resources API, and script editing.
  • Tighten Unity test cleanup and setup logic for temporary assets and folders to ensure reliable, isolated runs.

Summary by CodeRabbit

  • Tests
    • Centralized and reused test helpers across integration tests by introducing shared test utilities.
    • Removed multiple placeholder/skipped integration tests and obsolete test files to streamline the suite.
    • Strengthened, consolidated, and renamed unit/integration tests for clearer intent and more robust validations.
    • Widened a non-blocking timing assertion threshold to improve reliability under load.

✏️ Tip: You can customize this high-level summary in your review settings.

…ale tests

Python tests:
- Delete 3 vestigial placeholder files (test_script_editing.py, test_find_in_file_minimal.py, test_resources_api.py)
- Remove empty skip-marked tests from test_transport_framing.py and test_logging_stdout.py
- Consolidate DummyMCP/setup_tools() into test_helpers.py
- Fix flaky timing in test_telemetry_queue_worker.py (200ms → 500ms)
- Remove placeholder from test_instance_routing_comprehensive.py

C# tests:
- Consolidate MCPToolParameterTests.cs (755 → 361 lines, -52%)
- Fix 3 tests with stale "future feature" comments - features ARE implemented:
  - AutoGrow arrays (Phase 1.2)
  - Path normalization (Phase 1.1)
  - Bulk array mapping (Phase 3.1)
- Strengthen assertions in ManageGameObjectTests.cs and CommandRegistryTests.cs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 12, 2026

Reviewer's Guide

Cleans up and strengthens both Python and Unity test suites by removing vestigial/skip-only tests, consolidating shared helpers, and updating several C# integration tests to assert the system’s current behavior (auto-grow arrays, path normalization, bulk array mapping, and tool handler error paths) while tightening telemetry timing and command registry expectations.

File-Level Changes

Change Details Files
Consolidate script-tool test helpers and remove placeholder/duplicate Python tests.
  • Introduce DummyMCP and setup_script_tools() in a shared helper to register script-related tools via the registry.
  • Refactor multiple integration tests to import DummyContext/DummyMCP and use setup_script_tools() instead of local duplicates.
  • Delete vestigial placeholder tests and entire unused integration modules like minimal find-in-file, resources API, and script editing tests.
Server/tests/integration/test_helpers.py
Server/tests/integration/test_edit_normalization_and_noop.py
Server/tests/integration/test_get_sha.py
Server/tests/integration/test_edit_strict_and_warnings.py
Server/tests/integration/test_instance_routing_comprehensive.py
Server/tests/integration/test_transport_framing.py
Server/tests/integration/test_logging_stdout.py
Server/tests/integration/test_find_in_file_minimal.py
Server/tests/integration/test_resources_api.py
Server/tests/integration/test_script_editing.py
Update telemetry queue worker timing assertion to be robust in CI while still validating non-blocking behavior.
  • Relax upper bound on batched telemetry record() latency from 200ms to 500ms.
  • Clarify test comment to focus on non-blocking enqueue semantics rather than a strict low timing threshold.
Server/tests/integration/test_telemetry_queue_worker.py
Refactor MCPToolParameterTests to eliminate redundant cases and centralize setup/cleanup while retaining coverage of JSON/coercion scenarios.
  • Add EnsureTempFolders() helper and simplify TearDown cleanup for temp asset folders.
  • Replace multiple overlapping JSON parsing/material creation tests with a single focused GameObject JSON componentProperties test.
  • Collapse several JSON property handling tests into a single EndToEnd_PropertyHandling_AllScenarios test that covers the 10 documented behaviors, while simplifying assertions and removing debug noise.
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs
Convert “future feature” C# tests into concrete assertions of existing behavior (auto-grow arrays, path normalization, bulk array mapping).
  • Change array out-of-bounds test to assert that auto-grow actually resizes the backing array and sets the requested element.
  • Change friendly bracket-syntax path test to assert normalization and value application instead of expecting failure.
  • Change bulk array mapping test to assert that passing a JArray sets the entire array on the target ScriptableObject and validate contents.
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptableObjectStressTests.cs
Strengthen Unity command and registry tests to assert error/result semantics instead of only non-throw behavior.
  • Update CommandRegistry auto-discovery test to fetch each handler and assert it returns a non-null result when invoked with empty params.
  • Tighten ManageGameObject HandleCommand tests for null/empty params to assert that an ErrorResponse is returned with Success == false.
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/CommandRegistryTests.cs
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageGameObjectTests.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 12, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR centralizes test tool setup by adding DummyMCP and setup_script_tools() to test helpers, updates multiple Python integration tests to use the new helper, removes several placeholder/skipped tests, widens one timing assertion, and renames/strengthens several Unity C# tests.

Changes

Cohort / File(s) Summary
Test helper addition
Server/tests/integration/test_helpers.py
Added DummyMCP class and setup_script_tools() that register and collect script-related tools for tests.
Python tests switched to helper
Server/tests/integration/test_edit_normalization_and_noop.py, Server/tests/integration/test_edit_strict_and_warnings.py, Server/tests/integration/test_get_sha.py
Replaced local DummyMCP/setup_tools scaffolding with imported setup_script_tools(); adjusted imports and patch comments accordingly.
Removed / cleaned tests
Server/tests/integration/test_find_in_file_minimal.py, Server/tests/integration/test_resources_api.py, Server/tests/integration/test_script_editing.py, Server/tests/integration/test_transport_framing.py, Server/tests/integration/test_instance_routing_comprehensive.py, Server/tests/integration/test_logging_stdout.py
Deleted or emptied placeholder/skipped tests and removed an unimplemented parameterized test.
Timing assertion change
Server/tests/integration/test_telemetry_queue_worker.py
Increased non-blocking enqueue timing threshold from 200ms to 500ms and updated comments.
C# handler validation
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/CommandRegistryTests.cs
AutoDiscovery test now retrieves a handler and invokes it with empty params, asserting non-null return.
C# test consolidation & renames
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs
Consolidated many tests into end-to-end scenarios, added EnsureTempFolders(), renamed methods for clarity, broadened accepted shader cases, and reorganized fixture handling.
C# error/result tightening
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageGameObjectTests.cs
Tests now cast results to ErrorResponse and assert Success is false for invalid inputs.
C# stress test updates
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptableObjectStressTests.cs
Renamed tests and expanded verifications for auto-grow, friendly-syntax normalization, and full-array mapping, including asset reload checks.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • #297: Introduces/changes DummyMCP and centralized test tool registration patterns—closely related to setup_script_tools() addition.
  • #349: Modifies Unity MCP test suite and CommandRegistry tests; overlaps with C# test changes here.
  • #344: Updates Unity edit-mode tests and JSON parameter handling; related to the MCP tool parameter test consolidations.

Suggested reviewers

  • msanatan
  • Scriptwonder

Poem

🐰
I hopped through tests and tied each string,
Collected tools to make the suite sing.
Skipped the stubs, invoked the handler bright,
Renamed, tightened, and set thresholds right.
Carrot cheers for tidy test spring! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Clean up Unity and Python tests' accurately summarizes the main objective of the PR, which consolidates duplicates, removes placeholder tests, and harddens test suites across both Python and C# codebases.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62db5bf and 405c218.

📒 Files selected for processing (2)
  • Server/tests/integration/test_edit_normalization_and_noop.py
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In EndToEnd_PropertyHandling_AllScenarios, the texture-dependent scenarios (4/5/10) now silently skip if texPath doesn't exist; consider either creating the temp texture (as in the previous helper logic) or explicitly failing/inconclusive when the texture is missing so those behaviors don't accidentally go untested.
  • In CommandRegistryTests.AutoDiscovery_RegistersAllBuiltInTools, calling each handler with an empty JObject only asserts that it doesn't throw; you may want to additionally assert on the returned response shape (e.g., error vs success contract) so the test validates more than just handler existence.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `EndToEnd_PropertyHandling_AllScenarios`, the texture-dependent scenarios (4/5/10) now silently skip if `texPath` doesn't exist; consider either creating the temp texture (as in the previous helper logic) or explicitly failing/inconclusive when the texture is missing so those behaviors don't accidentally go untested.
- In `CommandRegistryTests.AutoDiscovery_RegistersAllBuiltInTools`, calling each handler with an empty `JObject` only asserts that it doesn't throw; you may want to additionally assert on the returned response shape (e.g., error vs success contract) so the test validates more than just handler existence.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
Server/tests/integration/test_edit_normalization_and_noop.py (1)

100-112: Remove unused tools_struct setup.

The tools_struct DummyMCP instance is populated (lines 102-112) but never used in the test. The test only uses apply_text from tools_text. This appears to be leftover code from the refactoring.

Proposed fix
 async def test_atomic_multi_span_and_relaxed(monkeypatch):
     tools_text = setup_script_tools()
     apply_text = tools_text["apply_text_edits"]
-    tools_struct = DummyMCP()
-    # Import the tools module to trigger decorator registration
-    import services.tools.script_apply_edits
-    # Get the registered tools from the registry
-    from services.registry import get_registered_tools
-    tools = get_registered_tools()
-    # Add all script-related tools to our dummy MCP
-    for tool_info in tools:
-        tool_name = tool_info['name']
-        if any(keyword in tool_name for keyword in ['script_apply', 'apply_edits']):
-            tools_struct.tools[tool_name] = tool_info['func']
     # Fake send for read and write; verify atomic applyMode and validate=relaxed passes through
     sent = {}

If tools_struct is indeed unused, also remove DummyMCP from the import on line 3.

TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs (1)

337-344: Test 10 uses texPath without verifying texture exists.

Tests 4 and 5 (lines 225, 239) correctly check if the texture exists before using texPath. However, test 10 assigns texPath to ["albedo"] without this guard. If the texture doesn't exist, the test may fail or produce inconsistent results.

🐛 Proposed fix - add existence check or remove texture assignment
                 // 10. Mixed friendly and alias keys in one go
                 var modify7 = new JObject
                 {
                     ["action"] = "modify",
                     ["path"] = matPath,
                     ["properties"] = new JObject
                     {
                         ["metallic"] = 0.8,
-                        ["smoothness"] = 0.3,
-                        ["albedo"] = texPath
+                        ["smoothness"] = 0.3
                     }
                 };
+                // Optionally add albedo only if texture exists
+                if (AssetDatabase.LoadAssetAtPath<Texture>(texPath) != null)
+                    ((JObject)modify7["properties"])["albedo"] = texPath;
🤖 Fix all issues with AI agents
In
@TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs:
- Around line 53-68: The TearDown method currently deletes TempDir, TempLiveDir
and "Assets/Temp" but does not call AssetDatabase.Refresh(), which can leave the
Unity asset database in a stale state for following tests; update the TearDown
(method TearDown in MCPToolParameterTests) to call AssetDatabase.Refresh() after
performing the deletions so the AssetDatabase reflects the removals (use
AssetDatabase.Refresh() or AssetDatabase.Refresh(ImportAssetOptions.Default) as
your project convention).
🧹 Nitpick comments (2)
Server/tests/integration/test_helpers.py (1)

64-68: Consider prefixing unused parameters to silence linter.

The args and kwargs are intentionally unused for API compatibility with the real MCP decorator, but static analysis flags them. Consider using underscore prefixes.

Proposed fix
-    def tool(self, *args, **kwargs):
+    def tool(self, *_args, **_kwargs):
         def deco(fn):
             self.tools[fn.__name__] = fn
             return fn
         return deco
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs (1)

43-51: Consider using [SetUp] for folder initialization.

The EnsureTempFolders() helper is manually called at the start of each test. For consistency with typical NUnit patterns and to ensure folders are always created before tests run, consider moving this to a [SetUp] method.

♻️ Suggested refactor
+        [SetUp]
+        public void SetUp()
+        {
+            EnsureTempFolders();
+        }
+
         private static void EnsureTempFolders()
         {
             // ... existing implementation
         }

Then remove the EnsureTempFolders() calls from lines 77 and 151.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53c0ed2 and 7c48e65.

📒 Files selected for processing (15)
  • Server/tests/integration/test_edit_normalization_and_noop.py
  • Server/tests/integration/test_edit_strict_and_warnings.py
  • Server/tests/integration/test_find_in_file_minimal.py
  • Server/tests/integration/test_get_sha.py
  • Server/tests/integration/test_helpers.py
  • Server/tests/integration/test_instance_routing_comprehensive.py
  • Server/tests/integration/test_logging_stdout.py
  • Server/tests/integration/test_resources_api.py
  • Server/tests/integration/test_script_editing.py
  • Server/tests/integration/test_telemetry_queue_worker.py
  • Server/tests/integration/test_transport_framing.py
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/CommandRegistryTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageGameObjectTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptableObjectStressTests.cs
💤 Files with no reviewable changes (6)
  • Server/tests/integration/test_logging_stdout.py
  • Server/tests/integration/test_instance_routing_comprehensive.py
  • Server/tests/integration/test_find_in_file_minimal.py
  • Server/tests/integration/test_resources_api.py
  • Server/tests/integration/test_transport_framing.py
  • Server/tests/integration/test_script_editing.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-29T15:23:17.871Z
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 491
File: MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs:78-115
Timestamp: 2025-12-29T15:23:17.871Z
Learning: In the MCPForUnity project, the team prefers to rely on their testing process to catch UI initialization issues rather than adding defensive null checks for UI elements in editor windows.

Applied to files:

  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageGameObjectTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs
📚 Learning: 2025-10-03T22:11:46.002Z
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 301
File: docs/CUSTOM_TOOLS.md:54-62
Timestamp: 2025-10-03T22:11:46.002Z
Learning: In Unity MCP, the `description` parameter in the `mcp_for_unity_tool` decorator is technically optional but should always be included as a best practice. Without it, there's a higher chance that MCP clients will not parse the tool correctly. All Unity MCP tools should include the description in the decorator for compatibility.

Applied to files:

  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs
🧬 Code graph analysis (5)
Server/tests/integration/test_get_sha.py (1)
Server/tests/integration/test_helpers.py (2)
  • DummyContext (16-55)
  • setup_script_tools (71-88)
Server/tests/integration/test_edit_strict_and_warnings.py (1)
Server/tests/integration/test_helpers.py (2)
  • DummyContext (16-55)
  • setup_script_tools (71-88)
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs (3)
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageGameObjectTests.cs (1)
  • TearDown (24-32)
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptableObjectStressTests.cs (1)
  • TearDown (63-84)
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/DomainReloadResilienceTests.cs (2)
  • TearDown (38-61)
  • Test (135-154)
Server/tests/integration/test_edit_normalization_and_noop.py (1)
Server/tests/integration/test_helpers.py (3)
  • DummyContext (16-55)
  • DummyMCP (58-68)
  • setup_script_tools (71-88)
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptableObjectStressTests.cs (2)
MCPForUnity/Editor/Tools/ManageScriptableObject.cs (1)
  • HandleCommand (40-75)
TestProjects/UnityMCPTests/Assets/Tests/EditMode/TestUtilities.cs (1)
  • JObject (21-25)
🪛 Ruff (0.14.10)
Server/tests/integration/test_helpers.py

64-64: Unused method argument: args

(ARG002)


64-64: Unused method argument: kwargs

(ARG002)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (22)
Server/tests/integration/test_telemetry_queue_worker.py (1)

37-40: LGTM! Reasonable threshold adjustment for CI stability.

The increase from 200ms to 500ms is pragmatic—50 non-blocking calls should still complete well under this limit (microseconds each), while the added headroom accommodates CI load variability. The comment clearly documents the rationale.

TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageGameObjectTests.cs (2)

34-44: LGTM! Assertions properly strengthened.

The test now verifies both the return type (ErrorResponse) and its state (Success == false), which is more robust than only checking for non-null. This pattern is consistent with similar tests later in the file (e.g., HandleCommand_WithPrefabPath_ReturnsGuidanceError_*).


46-57: LGTM! Consistent with the null params test.

The parallel strengthening of both error tests improves test coverage by verifying the expected response type and failure state. The comment on line 53 helpfully documents that the error is due to missing required action.

TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/CommandRegistryTests.cs (1)

46-52: LGTM! Strengthened test now verifies handler callability.

The updated assertions properly verify that each handler is:

  1. Registered and retrievable (not null)
  2. Callable without throwing exceptions
  3. Returns a non-null result for empty params

This is a meaningful improvement over just checking handler existence.

TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptableObjectStressTests.cs (4)

166-212: LGTM! Test correctly updated for implemented auto-grow feature.

The test name and assertions now properly reflect that auto-grow arrays is an implemented feature. The verification steps are thorough: checking patch success, array length (>= 100), and the value at index 99.


219-268: LGTM! Test correctly updated for implemented path normalization.

The test now properly verifies that friendly bracket notation (floatArray[2]) is normalized and works correctly. The added verification step (lines 262-265) that loads the asset and checks the value adds valuable end-to-end validation.


578-626: LGTM! Test correctly updated for implemented bulk array mapping.

The test name and assertions now properly reflect that bulk array mapping is implemented. Good use of CollectionAssert.AreEqual (line 623) to verify array contents match exactly, providing stronger validation than element-by-element checks.


630-630: No concerns with region header formatting.

Also applies to: 679-679

Server/tests/integration/test_edit_normalization_and_noop.py (3)

3-3: LGTM on the import consolidation.

The refactoring to use centralized setup_script_tools from test_helpers improves maintainability and reduces code duplication across test files.


7-9: Correct usage of the new helper.

The test correctly obtains tools via setup_script_tools() and accesses the apply_text_edits function for testing normalization behavior.


66-69: LGTM.

Straightforward refactoring to use the centralized helper.

Server/tests/integration/test_helpers.py (3)

1-14: LGTM on _DummyMeta implementation.

The class correctly provides attribute-style access to dict items with proper exception handling, and includes the model_extra property and model_dump method to mimic Pydantic model behavior.


16-55: Well-designed mock context.

The DummyContext class properly:

  • Generates unique session IDs to prevent test state leakage
  • Provides async log methods matching the real context API
  • Includes warn() as an alias for warning() for compatibility
  • Mimics FastMCP state management with get_state/set_state

71-88: LGTM on centralized tool setup.

The function correctly:

  • Imports the tools module to trigger decorator-based registration
  • Filters for script-related tools by name pattern
  • Returns a dict of tool functions for test use

One minor note: the mcp = DummyMCP() instance only uses its tools dict as a container. This is fine for consistency with the pattern, but a plain dict would also work.

Server/tests/integration/test_edit_strict_and_warnings.py (3)

3-3: Clean import consolidation.

Correctly imports only the needed helpers: DummyContext and setup_script_tools.


6-38: LGTM on test refactoring.

The test correctly uses the centralized setup_script_tools() helper while maintaining the original test logic for zero-based normalization warnings.


41-66: LGTM.

Correctly refactored to use centralized helpers.

Server/tests/integration/test_get_sha.py (2)

3-3: Clean import consolidation.

Correctly imports only the needed helpers from test_helpers.


6-33: LGTM on test refactoring.

The test correctly:

  • Uses the centralized setup_script_tools() helper
  • Verifies command routing to manage_script with action=get_sha
  • Validates parameter extraction from the URI
  • Confirms response filtering to only sha256 and lengthBytes
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs (3)

74-133: LGTM!

The test follows a clear naming convention, properly tests the JSON componentProperties coercion path, and includes comprehensive cleanup in the finally block with AssetDatabase.Refresh().


148-329: LGTM - Comprehensive end-to-end test consolidation.

The 10 scenarios cover diverse property handling paths with clear documentation. The use of LogAssert.Expect for invalid JSON handling (test 8) and tolerance-based color assertions (test 9) are appropriate.


349-358: LGTM!

The finally block properly cleans up all created resources (GameObject, Material, badJson asset) and calls AssetDatabase.Refresh() to ensure a clean state.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs (1)

332-333: Consider using AssertColorsEqual for consistency.

This inline tolerance check (0.02f) differs from the AssertColorsEqual helper (0.001f). If the wider tolerance is intentional due to shader switching precision, consider adding a comment explaining this, or extend the helper to accept a custom tolerance parameter.

♻️ Suggested refactor
-                Assert.IsTrue(Mathf.Abs(c9.r - 1f) < 0.02f && Mathf.Abs(c9.g - 1f) < 0.02f && Mathf.Abs(c9.b - 0f) < 0.02f,
-                    "Test 9: Color should be near yellow");
+                // Shader switching may introduce minor color precision loss
+                AssertColorsEqual(Color.yellow, c9, "Test 9: Color should be yellow");

Or if the wider tolerance is required:

private static void AssertColorsEqual(Color expected, Color actual, string message, float tolerance = 0.001f)
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c48e65 and 62db5bf.

📒 Files selected for processing (2)
  • Server/tests/integration/test_edit_normalization_and_noop.py
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • Server/tests/integration/test_edit_normalization_and_noop.py
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-10-03T22:11:46.002Z
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 301
File: docs/CUSTOM_TOOLS.md:54-62
Timestamp: 2025-10-03T22:11:46.002Z
Learning: In Unity MCP, the `description` parameter in the `mcp_for_unity_tool` decorator is technically optional but should always be included as a best practice. Without it, there's a higher chance that MCP clients will not parse the tool correctly. All Unity MCP tools should include the description in the decorator for compatibility.

Applied to files:

  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs
📚 Learning: 2025-09-03T16:00:55.839Z
Learnt from: dsarno
Repo: CoplayDev/unity-mcp PR: 0
File: :0-0
Timestamp: 2025-09-03T16:00:55.839Z
Learning: ComponentResolver in UnityMcpBridge/Editor/Tools/ManageGameObject.cs is a nested static class within ManageGameObject, not a sibling type. The `using static MCPForUnity.Editor.Tools.ManageGameObject;` import is required to access ComponentResolver methods directly without the outer class qualifier.

Applied to files:

  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs
📚 Learning: 2025-12-29T15:23:17.871Z
Learnt from: msanatan
Repo: CoplayDev/unity-mcp PR: 491
File: MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs:78-115
Timestamp: 2025-12-29T15:23:17.871Z
Learning: In the MCPForUnity project, the team prefers to rely on their testing process to catch UI initialization issues rather than adding defensive null checks for UI elements in editor windows.

Applied to files:

  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (3)
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/MCPToolParameterTests.cs (3)

70-133: LGTM!

The test is well-structured with proper setup, assertions, and cleanup in the finally block. The material assignment verification through JSON string coercion is thoroughly validated.


169-177: Good addition of explicit texture creation.

Creating the test texture programmatically ensures texture-dependent scenarios (4, 5, 10) run reliably without depending on external assets. This addresses the commit message objective of ensuring texture-dependent scenarios run properly.


43-51: Nice centralization of temp folder creation.

The EnsureTempFolders helper reduces duplication and ensures consistent test directory setup. The idempotent checks via IsValidFolder prevent errors on repeated calls.

- Remove unused tools_struct setup in test_edit_normalization_and_noop.py
- Create test texture in EndToEnd_PropertyHandling_AllScenarios so
  texture-dependent scenarios (4, 5, 10) actually run instead of silently skipping
- Add texture cleanup in finally block

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dsarno dsarno force-pushed the test-audit-cleanup branch from 62db5bf to 405c218 Compare January 12, 2026 04:25
@dsarno dsarno merged commit f4a8b05 into CoplayDev:main Jan 12, 2026
1 of 2 checks passed
@dsarno dsarno deleted the test-audit-cleanup branch January 15, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant