【问题标题】:Running ScalaTest suites (not tests) in parallel in sbt?在 sbt 中并行运行 ScalaTest 套件(不是测试)?
【发布时间】:2014-04-28 11:21:26
【问题描述】:

我使用 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)
  }
}

我看到 running tworunning one 之后 10 秒打印,这让我相信 run 2 直到 run 1 完成后才开始。

【问题讨论】:

    标签: sbt scalatest


    【解决方案1】:

    我不确定你在做什么不同,我已经使用 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
    

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

    【讨论】:

    • 这是正确的。 sbt 中的默认设置是并行执行,ScalaTest 中执行并行执行的默认方式是并行运行套件。唯一想到的是,如果您通过 Play 执行此操作,Play 将关闭并行执行。您可能希望尝试在 Test := true 中添加显式并行执行到您的构建。
    猜你喜欢
    • 2014-07-26
    • 2019-06-09
    • 2015-09-09
    • 2013-03-23
    • 2020-02-22
    • 2020-03-26
    • 2017-05-22
    • 2015-07-10
    • 2014-10-13
    相关资源
    最近更新 更多