如何在sbt控制台中加载测试配置jar

时间:2019-02-28 08:27:25

标签: scala sbt scalatest

我正在尝试在 sbt控制台(REPL)中编写scalatest。但是sbt控制台不会加载标记为测试配置的依赖项。

sbt console
scala> <console>:12: error: object scalatest is not a member of package org
   import org.scalatest._
              ^
Interpreter encountered errors during initialization!

$ sbt
sbt:scalatest-example> consoleProject

scala> (fullClasspath in Compile).eval.files foreach println
/home/ashok/scala/anagram/target/scala-2.12/classes
/home/ashok/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.8.jar

scala> (fullClasspath in Test).eval.files foreach println
/home/ashok/scala/anagram/target/scala-2.12/test-classes
/home/ashok/scala/anagram/target/scala-2.12/classes
/home/ashok/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.8.jar
/home/ashok/.ivy2/cache/org.scalatest/scalatest_2.12/bundles/scalatest_2.12-3.0.5.jar
/home/ashok/.ivy2/cache/org.scalactic/scalactic_2.12/bundles/scalactic_2.12-3.0.5.jar
/home/ashok/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.12.8.jar
/home/ashok/.ivy2/cache/org.scala-lang.modules/scala-xml_2.12/bundles/scala-xml_2.12-1.0.6.jar

我发现的解决方法是从scalatest中删除Test标签。但这并不理想。我想知道是否有更干净的方法可以在控制台中加载测试配置。

// libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" 

0 个答案:

没有答案