为什么scalatest会混淆输出?

Rog*_*ach 14 scala sbt scalatest

我从sbt运行我的scalatest,输出混合起来 - scalatest打印所有测试运行,并对它们发表评论,并在中间某处打印统计信息:

> test
[info] Compiling 1 Scala source to /home/platon/Tor/scala-dojo-02/target/scala-2.9.1/classes...
[info] FunsWithListsTests:
[info] - should return list of labels
[info] - should return the average rating of games belonging to Zenga
[info] - should return the total ratings of all games
[info] - should return the total ratings of EA games *** FAILED ***
[info]   0 did not equal 170 (FunsWithListsTests.scala:35)
[error] Failed: : Total 8, Failed 5, Errors 0, Passed 3, Skipped 0
[info] - should increase all games rating by 10 *** FAILED ***
[error] Failed tests:
[error]     dojo.FunsWithListsTests
[info]   List() did not equal List(Game(Activision,40), Game(Zenga,70), Game(Zenga,20), Game(EA,70), Game(EA,120)) (FunsWithListsTests.scala:40)
[info] - should decrease all Zenga games rating by 10 *** FAILED ***
[info]   List() did not equal List(Game(Activision,30), Game(Zenga,50), Game(Zenga,0), Game(EA,60), Game(EA,110)) (FunsWithListsTests.scala:45)
[info] - should create function to find Activision games *** FAILED ***
[info]   List(Game(Activision,30), Game(Zenga,60), Game(Zenga,10), Game(EA,60), Game(EA,110)) did not equal List(Game(Activision,30)) (FunsWithListsTests.scala:50)
[info] - should return a List of tuples consisting of game label and game *** FAILED ***
[info]   List() did not equal List((ACTIVISION,Game(Activision,30)), (ZENGA,Game(Zenga,60)), (ZENGA,Game(Zenga,10)), (EA,Game(EA,60)), (EA,Game(EA,110))) (FunsWithListsTests.scala:56)
[error] {file:/home/platon/Tor/scala-dojo-02/}default-940f03/test:test: Tests unsuccessful
[error] Total time: 1 s, completed Mar 20, 2012 9:27:13 AM
Run Code Online (Sandbox Code Playgroud)

似乎如果我要积累大量的测试,那么搜索那些统计数据和失败的测试将会变得很痛苦.

有没有办法来解决这个问题?

Edm*_*984 7

在我看来,原因是SBT默认情况下并行执行测试,就像maven-surefire-plugin一样.

正如在ScalaTest wiki中解释的那样,这可以通过以下方式解决:

禁用并行执行测试默认情况下,sbt并行运行所有任务.由于每个测试都映射到一个任务,因此默认情况下测试也会并行运行.要禁用并行执行测试:

test中的parallelExecution:= false