[Repo Assist] Fix Test Explorer hierarchy when test names contain '.' or '+' separators#2133
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
Conversation
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>
Contributor
Author
|
✅ Pull request created: #2133 |
This was referenced Feb 22, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🤖 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+CalculationsorMyNamespace.MyClass) but breaks when these characters appear within the test name itself:+in the name create an indented result in the test explorer #2007): test"a + b = c should work"gets split intoa→b = c should work.then the Test explorer is going to create a new branch/node #2013): test methodfoo.bar(containing a literal.) gets split intofoo→barFix
Three targeted changes to
TestExplorer.fs:splitSegmentsWithKnownLeaf– a new function that takes theDisplayNameas a hint to identify the leaf segment and avoids splitting within it. If the full name ends with"." + displayNameor"+" + displayName, the prefix is split normally and the display name is appended as the leaf.inferHierarchyWithDisplayNames– a variant ofinferHierarchythat usessplitSegmentsWithKnownLeafper item instead ofsplitSegments, used in the discovery path.mapDtosForProject– updated to useinferHierarchyWithDisplayNamesso that test DTOs from the language server are hierarchised correctly.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
ofTestDTOs) relies on theDisplayNamefrom the language server DTO, which is always available. ThegetOrMakeHierarchyPathfallback path (for TRX results without prior discovery) still usessplitSegments— this is an uncommon path and can be improved separately.tryGetByIdis 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