测试 SBT 期间类路径中的测试 jar

Test-jar in Classpath during Test SBT

我们在两个独立的 jar 中有一个 Stub classes 和 Real classes 的 disptach-reboot。我们在 SBT 中需要一种方法,以便当单元测试为 运行 时,我们需要 class 路径中的 Stub classes 和代码 运行ning 中的 Real classes生产。

使用 multi-project .sbt build definition and unmanaged dependencies:

lazy val commonSettings = Seq(
  dependencyClasspath in Compile += baseDirectory.value / "lib-main" / "realclasses.jar",
  dependencyClasspath in Runtime += baseDirectory.value / "lib-main" / "realclasses.jar",
  dependencyClasspath in Test    += baseDirectory.value / "lib-test" / "stubclasses.jar"
)

lazy val root = (project in file(".")).settings(commonSettings: _*)