How to run a single test in SBT
Note to self. Maybe one day I will finally remember how to run a single test class in sbt. Currently, I must google that every time I need it.
When you want to run tests from a single test class using the command line (not from the sbt interactive mode), you probably write this:
1
sbt testOnly name.mikulskibartosz.TestClass
This is wrong! It runs all of the tests.
The correct way of running a single test class looks like this:
1
sbt "testOnly name.mikulskibartosz.TestClass"
Please remember about the quotation.
Did you enjoy reading this article?
Would you like to learn more about leveraging AI to drive growth and innovation, software craft in data engineering, and MLOps?
Subscribe to the newsletter or add this blog to your RSS reader (does anyone still use them?) to get a notification when I publish a new essay!
You may also like

Bartosz Mikulski
- MLOps engineer by day
- AI and data engineering consultant by night
- Python and data engineering trainer
- Conference speaker
- Contributed a chapter to the book "97 Things Every Data Engineer Should Know"
- Twitter: @mikulskibartosz
- Mastodon: @mikulskibartosz@mathstodon.xyz