从"sbt test"运行测试时,类路径与从 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项目中。当从想法中运行此操作时,此测试成功了,因为它包含我在build.sbt中指定的所有libraryDependencies

但是,在执行sbt test时,它失败了,因为它仅包含/opt/sbt/bin/sbt-launch.jar

现在,我有一个测试,依赖对此Runtime class Path的填充。

是否可以以某种方式填充它?

这是Runtime

的Real SBT Class Path的重复

要使它起作用,我必须在我的build.sbt中包括:

fork in Test := true

最新更新