问题
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.
回答1:
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)
来源:https://stackoverflow.com/questions/17031333/importing-test-classes-into-scala-console-in-sbt