Skip to content

[Repo Assist] Fix Test Explorer hierarchy when test names contain '.' or '+' separators#2133

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/fix-test-name-separator-hierarchy-547e036b4eaa7aca
Draft

[Repo Assist] Fix Test Explorer hierarchy when test names contain '.' or '+' separators#2133
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/fix-test-name-separator-hierarchy-547e036b4eaa7aca

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Fixes a bug where the Test Explorer incorrectly splits test names on . and + characters when building the hierarchy tree, causing spurious extra levels in the explorer.

Root Cause

TestName.segmentRegex (([+\.]?)([^+\.]+)) splits the flat full test name on every occurrence of . and +. This works for structural separators (e.g. Tests+Calculations or MyNamespace.MyClass) but breaks when these characters appear within the test name itself:

Fix

Three targeted changes to TestExplorer.fs:

  1. splitSegmentsWithKnownLeaf – a new function that takes the DisplayName as a hint to identify the leaf segment and avoids splitting within it. If the full name ends with "." + displayName or "+" + displayName, the prefix is split normally and the display name is appended as the leaf.

  2. inferHierarchyWithDisplayNames – a variant of inferHierarchy that uses splitSegmentsWithKnownLeaf per item instead of splitSegments, used in the discovery path.

  3. mapDtosForProject – updated to use inferHierarchyWithDisplayNames so that test DTOs from the language server are hierarchised correctly.

  4. tryGetById – simplified from segment-based tree navigation to a plain recursive ID-equality search. The old approach could also misidentify nodes for test names with separators.

Trade-offs

  • The fix for the discovery path (ofTestDTOs) relies on the DisplayName from the language server DTO, which is always available. The getOrMakeHierarchyPath fallback path (for TRX results without prior discovery) still uses splitSegments — this is an uncommon path and can be improved separately.
  • tryGetById is now O(n) in tree size rather than O(depth). For typical test suites this is negligible.

Test Status

Build was not possible in this environment (no node_modules). The changes are in pure F# logic. The fix has been manually traced through the affected code paths and is consistent with the existing type signatures and module structure.

Closes #2007
Closes #2013
Related to #1960

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@ee50a3b7d1d3eb4a8c409ac9409fd61c9a66b0f5. View source at https://github.com/githubnext/agentics/tree/ee50a3b7d1d3eb4a8c409ac9409fd61c9a66b0f5/workflows/repo-assist.md.

The segmentRegex splits full test names on '.' and '+' characters to
infer the tree hierarchy in the Test Explorer. This causes problems when:

- Expecto test names contain '+' (e.g. 'a + b = c should work')
- NUnit/xUnit test method names contain '.' (e.g. 'foo.bar')

Both create extra, incorrect hierarchy levels in the Test Explorer.

Changes:
- Add splitSegmentsWithKnownLeaf that uses the DisplayName as a hint
  for the leaf segment, avoiding splitting within the test name itself
- Add inferHierarchyWithDisplayNames that uses this smarter splitter
- Use inferHierarchyWithDisplayNames in mapDtosForProject so that test
  discovery via the language server correctly builds the hierarchy
- Simplify tryGetById to use recursive ID search, removing the
  segment-based navigation that could fail for names with separators

Fixes #2007 (Expecto '+' in test names)
Fixes #2013 ('.' in test names creates extra hierarchy nodes)
Related to #1960 (test name hierarchy issues)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

✅ Pull request created: #2133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

0 participants