Live unit testing with sbt

When I look at Visual Studio, there is one feature I would like to have in IntelliJ — live unit testing. In fact, I have to be more specific. If it were added to IntelliJ, it would probably work only with Java. I need such a feature in sbt. I need it to test Scala code.

Fortunately, there is something similar available. It does not have an excellent UX. You cannot record a 10 minutes long video tutorial about it, because it is too simple. Definitely, it is not perfect. However, in my opinion, it is good enough and gets the job done.

To get live unit testing in sbt, open a terminal window, navigate to your project directory, run sbt in interactive mode, and then run this command:

1
~test

It periodically looks for changes in your code and runs the relevant tests.

You can even run it in the “sbt-shell” window in IntelliJ and use the window “Floating mode” to make it always visible on the side of the screen.

Live unit testing with sbt with a floating sbt-shell window
Live unit testing with sbt with a floating sbt-shell window

Did you enjoy reading this article?
Would you like to learn more about 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!

Newsletter

Do you enjoy reading my articles?
Subscribe to the newsletter if you don't want to miss the new content, business offers, and free training materials.

Bartosz Mikulski

Bartosz Mikulski

  • Data/MLOps engineer by day
  • DevRel/copywriter by night
  • Python and data engineering trainer
  • Conference speaker
  • Contributed a chapter to the book "97 Things Every Data Engineer Should Know"
  • Twitter: @mikulskibartosz
Newsletter

Do you enjoy reading my articles?
Subscribe to the newsletter if you don't want to miss the new content, business offers, and free training materials.