当 运行 从 "sbt test" 测试时,类路径与从 IDEA 测试 运行 时不同
When running tests from "sbt test" the classpath is different than when running from IDEA
我有以下简单测试:
class ClasspathTest extends FlatSpec with Matchers {
"The classpath" should "have more than one member" in {
System.getProperty("java.class.path").split(":").length should be > 1
}
}
这位于 sbt 项目中。当运行这个来自IDEA时,这个测试成功了,因为它包含了我在build.sbt
.
中指定的所有libraryDependencies
然而,当执行 sbt test
时它失败了,因为它只包含 /opt/sbt/bin/sbt-launch.jar
.
现在我有一个测试依赖于完全填充这个运行时类路径。
是否可以通过某种方式填充它?
这是 Real SBT Classpath at Runtime
的副本
为了让它工作,我必须在我的 build.sbt 中包含:
fork in Test := true
我有以下简单测试:
class ClasspathTest extends FlatSpec with Matchers {
"The classpath" should "have more than one member" in {
System.getProperty("java.class.path").split(":").length should be > 1
}
}
这位于 sbt 项目中。当运行这个来自IDEA时,这个测试成功了,因为它包含了我在build.sbt
.
libraryDependencies
然而,当执行 sbt test
时它失败了,因为它只包含 /opt/sbt/bin/sbt-launch.jar
.
现在我有一个测试依赖于完全填充这个运行时类路径。
是否可以通过某种方式填充它?
这是 Real SBT Classpath at Runtime
的副本为了让它工作,我必须在我的 build.sbt 中包含:
fork in Test := true