在sbt中并行运行ScalaTest套件(而不是测试)?

rxi*_*xin 5 sbt scalatest

我使用SBT 0.13.1并希望并行运行ScalaTest测试套件(不是每个套件中的测试).

不是已经parallelExecution in Test := false确定,但它看起来像测试套件以串行顺序运行.

我做的实验是:

class BlahSuite extends FunSuite {
  test("run 1") {
    println("running one")
    Console.err.flush()
    Console.out.flush()
    Thread.sleep(10000)
  }
}

class Blah2Suite extends FunSuite{
  test("run 2") {
    println("running two")
    Console.err.flush()
    Console.out.flush()
    Thread.sleep(10000)
  }
}
Run Code Online (Sandbox Code Playgroud)

我看到running two10秒后印刷running one,这让我相信run 2直到run 1完成才开始.

小智 0

我不确定你在做什么不同的事情,我已使用 Scala 2.10.3 将你的代码复制到一个空的 SBT 项目 (0.13.1) 中,并且默认情况下它并行运行,请参阅我的输出:

running one
running two
[info] Blah2Suite:
[info] - run 2
[info] BlahSuite:
[info] - run 1
[info] Run completed in 10 seconds, 278 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 2, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 11 s, completed Mar 21, 2014 11:58:24 AM
Run Code Online (Sandbox Code Playgroud)

使用 ScalaTest 版本 2.1.0 和 2.0 进行了尝试。

  • 这是对的。sbt 中默认是并行执行,ScalaTest 中默认并行执行方式是并行运行 Suites。唯一想到的是,如果您通过 Play 执行此操作,Play 会关闭并行执行。您可能希望尝试在 Test := true 中添加显式的并行执行到您的构建中。 (3认同)