Importing test classes into Scala console in sbt?

∥☆過路亽.° 提交于 2020-01-01 03:58:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!