Skip to content

[2.x] feat: testOnly as a command#8607

Merged
eed3si9n merged 5 commits intosbt:developfrom
calm329:fix/3188-testonly-fail-no-match
Jan 22, 2026
Merged

[2.x] feat: testOnly as a command#8607
eed3si9n merged 5 commits intosbt:developfrom
calm329:fix/3188-testonly-fail-no-match

Conversation

@calm329
Copy link
Copy Markdown
Contributor

@calm329 calm329 commented Jan 22, 2026

Summary

Adds testOnly command that fails when no tests match the specified patterns across all aggregated subprojects.

Problem

Running testOnly somePattern from a root project that aggregates multiple subprojects silently passes even when no tests match the pattern anywhere. This is a CI reliability issue - typos in test names go undetected for days.

Solution

New command testOnly that:

  • Runs definedTestNames across all aggregated subprojects
  • Fails if no tests match, showing available tests
  • Runs testSelected if matches found
> testOnly NonExistentTest
[error] No tests match the patterns: NonExistentTest
[error] Available tests:
[error]   - example.HelloTest
[error]   - example.WorldTest

Fixes #3188

@calm329 calm329 force-pushed the fix/3188-testonly-fail-no-match branch from 42f5dda to 2433d48 Compare January 22, 2026 06:08
@calm329
Copy link
Copy Markdown
Contributor Author

calm329 commented Jan 22, 2026

@eed3si9n I'm not sure why those two CI checks got failed. Would you mind taking a look please?

@eed3si9n
Copy link
Copy Markdown
Member

There's a tab completion that's testing for testOnly it seems:

[info] - testOnly completions *** FAILED ***
[info]   List("testOnly", "testOnly/", "testOnly;", "testOnlyCommand") did not equal Vector("testOnly", "testOnly/", "testOnly;") (ClientTest.scala:160)
[info]   Analysis:
[info]   List(3: "testOnlyCommand" -> )

@eed3si9n
Copy link
Copy Markdown
Member

Thinking aloud, I wonder if we can make the new command named testOnly and add a task called testFilter, so we'd keep the same UX of sbt testOnly ...FooTest?

@calm329
Copy link
Copy Markdown
Contributor Author

calm329 commented Jan 22, 2026

Thinking aloud, I wonder if we can make the new command named testOnly and add a task called testFilter, so we'd keep the same UX of sbt testOnly ...FooTest?

Yeah, that's a good idea. Let me implement it

@eed3si9n eed3si9n changed the title Add testOnlyCommand that fails when no tests match [2.x] feat: testOnly as a command Jan 22, 2026
Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

Thanks!

@eed3si9n eed3si9n merged commit 2380ab8 into sbt:develop Jan 22, 2026
19 of 23 checks passed
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.

sbt testOnly command should fail/warn when no test found

2 participants