【问题标题】:Output from scalatest is not synchronized with output from the testsscalatest 的输出与测试的输出不同步
【发布时间】:2018-10-06 16:01:10
【问题描述】:

我有一套 scalatest 测试,它们在运行时使用 println 将信息输出到控制台。

当我使用 Eclipse Scala 插件(使用上下文菜单中的Run As ... / 3 ScalaTest - File)运行该套件时,控制台会输出关于哪些测试通过和哪些失败的附加输出。我猜这个输出来自跑步者。

问题是我的代码中的行和运行器中的行没有明智地交错。就好像它们是从两个不同步的不同线程中打印出来的。

例如这里是运行的输出

>>>>>>>>>>>>>Starting The parser should warn when the interface name at the end does not match >>>>>>>>>>>>>>>>>>
(interface Fred 
interface Bob)
-----------------------------
File: <unknown> line: 2 column: 11 Name does not match.
----The AST after parsing-------------

[ IntfDeclNd( (), (), () ) ]

---------------------------------------
<<<<<<<<<<<<<Finished The parser should warn when the interface name at the end does not match <<<<<<<<<<<<<<<<<
>>>>>>>>>>>>>Starting The parser should parse a class with generic args >>>>>>>>>>>>>>>>>>
(class Fred{type a, type b extends B}() class)
- should parse multiline comment at end of file *** FAILED ***
  Expected 0, but got 1 (TestsBase.scala:103)
- should fail on incomplete multiline comment
- should parse single line comments
- should allow a class name to be repeated at the end
- should warn when the class name at the end does not match
- should allow an interface name to be repeated at the end
- should warn when the interface name at the end does not match
----The AST after parsing-------------

以“- should”或“Expected”开头的行来自跑步者,您可以看到其中一堆被插入我的一个测试的输出中间。跑步者的其他输出出现在其他地方,这还不是全部。

我的问题:为什么会这样?有没有办法让跑步者的输出与我的输出相协调?

【问题讨论】:

    标签: scalatest


    【解决方案1】:

    很可能,这些套件是并行运行的。

    http://www.scalatest.org/user_guide/using_the_runner#executingSuitesInParallel

    随着多核架构的普及,以及经常 测试的可并行性,能够运行测试很有用 在平行下。 [...]

    -P 选项可以选择附加一个数字(例如“-P10”-- 没有中间空间)来指定要创建的线程数 在线程池中。如果未指定数字(或 0),则 线程将根据可用处理器的数量来决定。

    所以基本上将 -P1 传递给跑步者。对于 Eclipse,该位置可能是“参数”选项卡。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-03
      • 1970-01-01
      • 2012-01-08
      • 2012-10-20
      • 1970-01-01
      • 1970-01-01
      • 2018-05-18
      相关资源
      最近更新 更多