Live unit testing with sbt

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

Remember to share on social media!
If you like this text, please share it on Facebook/Twitter/LinkedIn/Reddit or other social media.

If you watch programming live streams, check out my YouTube channel.
You can also follow me on Twitter: @mikulskibartosz

For business inquiries, send me a message on LinkedIn or Twitter.


Bartosz Mikulski
Bartosz Mikulski * data scientist / software engineer * conference speaker * organizer of School of A.I. meetups in Poznań * co-founder of Software Craftsmanship Poznan & Poznan Scala User Group