Skip to content

fix: TestDiscovery items missing test_case/test_group tags causes Run in Terminal to run entire file#103

Open
tudorbertiean wants to merge 1 commit into
st0012:mainfrom
tudorbertiean:fix/test-discovery-missing-tags
Open

fix: TestDiscovery items missing test_case/test_group tags causes Run in Terminal to run entire file#103
tudorbertiean wants to merge 1 commit into
st0012:mainfrom
tudorbertiean:fix/test-discovery-missing-tags

Conversation

@tudorbertiean
Copy link
Copy Markdown

@tudorbertiean tudorbertiean commented Apr 23, 2026

The problem

When clicking "Run in Terminal" on a specific test in the Test Explorer, the generated command runs the entire spec file instead of just that test.

resolve_test_commands (link) uses test_case and test_group tags to decide whether to include a line number in the command. But TestDiscovery never sets those tags — items only ever get ["framework:rspec"]. So every item falls through to the else branch, which adds the full file path with no line number.

Other options considered

1. Fix the else branch in resolve_test_commands — infer intent from structure: leaf nodes (no children) are test cases and should include a line number. This works but sidesteps the root cause and leaves the test_case/test_group branches as unreachable dead code.

2. Add add_tag to TestItem in ruby-lsp — the cleanest fix long-term, since TestItem is the right home for this and it would be part of the public addon API. The reason it doesn't exist is that the built-in Minitest listener lives inside ruby-lsp and can access @tags directly, so there was never pressure to expose it.

Test plan

  • Added test_group/test_case tag assertions to test_discovery_spec.rb
  • Added add_tag test to spec_style_patch_spec.rb
  • bundle exec srb tc — no errors
  • bundle exec rspec — all examples pass

… in Terminal to run entire file

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@tudorbertiean
Copy link
Copy Markdown
Author

@st0012 let me know what you think - open to any feedback on this one

@tudorbertiean tudorbertiean force-pushed the fix/test-discovery-missing-tags branch from 7317058 to a7f7db4 Compare April 23, 2026 16:28
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