为特定SBT配置设置testFrameworks

时间:2014-02-12 12:26:25

标签: scala sbt scalameter

我正在尝试将ScalaMeter集成到我们构建的单独配置中。我想在单独的配置中运行所有性能测试,因为它们自然很慢。在Build.scala我有:

  lazy val ItTest = config("it").extend(Test)

  lazy val PerfTest = config("perf").extend(Test)

  val testSettings = Seq(
    testOptions in Test := Seq(Tests.Filter(x => !itFilter(x))),
    testOptions in ItTest := Seq(Tests.Filter(x => itFilter(x))),
    testFrameworks in PerfTest := Seq(new TestFramework("org.scalameter.ScalaMeterFramework")),
    logBuffered in PerfTest := false,
    // testOptions in PerfTest := Seq(Tests.Filter(perfFilter)),
    // needed thanks to http://stackoverflow.com/questions/7898273/how-to-get-logging-working-in-scala-unit-tests-with-testng-slf4s-and-logback
    parallelExecution in Test := false,
    parallelExecution in ItTest := false,
    parallelExecution in PerfTest := false)

 lazy val project1 = project.configs(ItTest, PerfTest).settings(testSettings: _*) // etc

testFrameworks按预期设置:

> show *:testFrameworks
[info] project1/*:testFrameworks
[info]  List(TestFramework(WrappedArray(org.scalacheck.ScalaCheckFramework)), TestFramework(WrappedArray(org.specs2.runner.Specs2Framework, org.specs2.runner.SpecsFramework)), TestFramework(WrappedArray(org.specs.runner.SpecsFramework)), TestFramework(WrappedArray(org.scalatest.tools.Framework, org.scalatest.tools.ScalaTestFramework)), TestFramework(WrappedArray(com.novocode.junit.JUnitFramework)))
[info] project2/*:testFrameworks
[info]  List(TestFramework(WrappedArray(org.scalacheck.ScalaCheckFramework)), TestFramework(WrappedArray(org.specs2.runner.Specs2Framework, org.specs2.runner.SpecsFramework)), TestFramework(WrappedArray(org.specs.runner.SpecsFramework)), TestFramework(WrappedArray(org.scalatest.tools.Framework, org.scalatest.tools.ScalaTestFramework)), TestFramework(WrappedArray(com.novocode.junit.JUnitFramework)))
[info] all/*:testFrameworks
[info]  List(TestFramework(WrappedArray(org.scalacheck.ScalaCheckFramework)), TestFramework(WrappedArray(org.specs2.runner.Specs2Framework, org.specs2.runner.SpecsFramework)), TestFramework(WrappedArray(org.specs.runner.SpecsFramework)), TestFramework(WrappedArray(org.scalatest.tools.Framework, org.scalatest.tools.ScalaTestFramework)), TestFramework(WrappedArray(com.novocode.junit.JUnitFramework)))
> show perf:testFrameworks
[info] project1/perf:testFrameworks
[info]  List(TestFramework(WrappedArray(org.scalameter.ScalaMeterFramework)))
[info] project2/perf:testFrameworks
[info]  List(TestFramework(WrappedArray(org.scalameter.ScalaMeterFramework)))
[info] all/perf:testFrameworks
[info]  List(TestFramework(WrappedArray(org.scalameter.ScalaMeterFramework)))

Howewer,perf:test运行ScalaTest测试,并且不运行ScalaMeter测试(反之亦然,如预期的那样)。我该如何解决这个问题?

SBT版本0.13.1以及0.13.0会发生这种情况。

1 个答案:

答案 0 :(得分:3)