scalatest 的输出与测试的输出不同步
Output from scalatest is not synchronized with output from the tests
我有一套 scalatest 测试,它们使用 println 将信息输出到控制台,因为它们 运行。
当我 运行 套件使用 Eclipse Scala 插件时(使用上下文菜单中的 Run As ... / 3 ScalaTest - File
),控制台会额外输出关于哪些测试通过和哪些失败的信息。我猜这个输出来自 运行ner.
问题是我的代码行和 运行ner 的代码行没有合理地交错。就好像它们是从两个不同步的不同线程打印出来的。
例如,这里是 运行
的输出
>>>>>>>>>>>>>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" 开头的行来自 运行ner,你可以看到其中一堆被插入到我的一个测试的输出中间. 运行ner 的其他输出出现在其他地方,这不是全部。
我的问题:为什么会这样?有什么方法可以让 运行ner 的输出与我的输出相协调吗?
很可能,这些套件是 运行 并行的。
http://www.scalatest.org/user_guide/using_the_runner#executingSuitesInParallel
With the proliferation of multi-core architectures, and the often
parallelizable nature of tests, it is useful to be able to run tests
in parallel. [...]
The -P option may optionally be appended with a number (e.g. "-P10" --
no intervening space) to specify the number of threads to be created
in the thread pool. If no number (or 0) is specified, the number of
threads will be decided based on the number of processors available.
所以基本上将 -P1 传递给跑步者。对于 eclipse,该位置可能是“参数”选项卡。
我有一套 scalatest 测试,它们使用 println 将信息输出到控制台,因为它们 运行。
当我 运行 套件使用 Eclipse Scala 插件时(使用上下文菜单中的 Run As ... / 3 ScalaTest - File
),控制台会额外输出关于哪些测试通过和哪些失败的信息。我猜这个输出来自 运行ner.
问题是我的代码行和 运行ner 的代码行没有合理地交错。就好像它们是从两个不同步的不同线程打印出来的。
例如,这里是 运行
的输出>>>>>>>>>>>>>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" 开头的行来自 运行ner,你可以看到其中一堆被插入到我的一个测试的输出中间. 运行ner 的其他输出出现在其他地方,这不是全部。
我的问题:为什么会这样?有什么方法可以让 运行ner 的输出与我的输出相协调吗?
很可能,这些套件是 运行 并行的。
http://www.scalatest.org/user_guide/using_the_runner#executingSuitesInParallel
With the proliferation of multi-core architectures, and the often parallelizable nature of tests, it is useful to be able to run tests in parallel. [...]
The -P option may optionally be appended with a number (e.g. "-P10" -- no intervening space) to specify the number of threads to be created in the thread pool. If no number (or 0) is specified, the number of threads will be decided based on the number of processors available.
所以基本上将 -P1 传递给跑步者。对于 eclipse,该位置可能是“参数”选项卡。