I am building a Scala project in the standard directory layout using sbt. I want to run sbt console
and import my unit tests so that I can play with them in the Scala REPL. What is the easiest way to do this? Is there a command I can pass to sbt, or something I can add to build.sbt
?
Note that I don't necessarily want to run unit tests from the sbt console
. (Though that would be nice too.) Instead a have test fixtures that set up data structures that I want to use in my REPL session.
ScalaTest is one of the main testing libraries for Scala projects, and in this lesson you'll see how to create a Scala project that uses ScalaTest. You'll also be able to compile, test, and run the project with sbt.
By default, sbt executes tasks in parallel (subject to the ordering constraints already described) in an effort to utilize all available processors. Also by default, each test class is mapped to its own task to enable executing tests in parallel.
We have a build. sbt file that is used for multiple projects. Doing sbt test:compile compiled the tests for every single project and took over 30 minutes.
Use test
configuration scope, like this:
sbt> test:console
For more information, see Scopes in the sbt documentation.
With specs2 for example, you can go:
sbt> test:console console> import mytestpackage._ console> import org.specs2._ console> specs2.run(new MySpec)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With