sbt 12自定义测试目录

时间:2013-04-01 22:33:11

标签: scala sbt

我从sbt 11升级到sbt 12.2,我们目前有以下项目结构:

src
  main
    scala/...
  test
    shared
      scala/...
    unit
      scala/...
    integration
      scala/...
    functional
      scala/...

当我升级到sbt 12时,测试不再运行,我们得到:No tests to run for unit:test。看一下sbt 12文档,为了使它能够开箱即用,我们需要重新构建测试源的文件夹和包结构。但是,我想在重新构建之前检查是否还有其他任何我们可以做的事情。

我们的测试配置如下(仅显示单元测试配置,其他测试类型具有相同配置):

lazy val project = Project(ID, BASE, settings = platformSettings)
.configs(Shared)
.configs(UnitTests)

lazy val Shared = config("shared").extend(Runtime)
lazy val sharedSettings = configure(Shared, "shared")

lazy val UnitTests = config("unit") extend(Shared)
lazy val unitTestSettings = configure(UnitTests, "unit")

private def configure(configuration: Configuration, testType: String) = {
  inConfig(configuration)(Defaults.testSettings) ++ inConfig(configuration)(settingsFor(testType))
}

private def settingsFor(testType: String): Seq[Setting[_]] = Seq (
  sourceDirectory <<= baseDirectory(_ / "src" / "test" / testType),
  testListeners <<= (target in Compile).map({ (target) => Seq(new JUnitXmlTestsListener(target.getAbsolutePath()))}),
  parallelExecution := false
)

0 个答案:

没有答案