【问题标题】:Delay between Scala test classesScala 测试类之间的延迟
【发布时间】:2015-02-10 07:37:08
【问题描述】:

在使用 SBT 作为构建工具的 Scalatest 中。我将包的所有测试作为 sbt "testOnly package.*" 运行。我想通过 sbt 构建定义在该包的不同类之间延迟运行,即不想改变内部类,怎么办?

注意-我已经在使用 测试中的 parallelExecution := false 在我的构建定义中,但我也想在不同的测试类执行之间给出延迟。

【问题讨论】:

    标签: scala sbt scalatest


    【解决方案1】:

    您可以使用 test-listeners 接口:

    testListeners += new TestReportListener {
      def startGroup(name: String): Unit = println(s"Start Group $name")
      def endGroup(name: String, result: TestResult.Value): Unit =
        println(s"End Group $name (succeeded)")
      //
      def endGroup(name: String, t: Throwable): Unit = 
        println(s"End Group $name (failed)")
      //
      def testEvent(event: TestEvent): Unit = 
        println(s"Test Event: ${event.result}")
    }
    

    然后在组(文件)或单个测试之间插入Thread.sleep。不是很优雅,但我想它会起作用。

    【讨论】:

      猜你喜欢
      • 2012-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-15
      • 2020-07-27
      • 2018-09-19
      • 2019-09-16
      • 1970-01-01
      相关资源
      最近更新 更多