2014-12-12 85 views
5

我正在使用sbt和JUnit来运行大型Scala项目的测试。我是forking multiple JVMs进行测试,并定义如何使用testGrouping in Test将测试分组到JVM中。如何并行运行测试,但得到整齐有序的测试输出?

测试并行运行,但是它们的输出相互交错,因此很难通读。我已经设置了logBuffered in Test := true,但这似乎没有做任何事情。

下面是一个片段我settings

parallelExecution in Test := true, 
testForkedParallel in Test := false, 
concurrentRestrictions in Global := Seq(Tags.limit(Tags.ForkedTestGroup, 8)), 

testGrouping in Test := (definedTests in Test, javaOptions in Test) map groupBySuite, 
testGrouping in Test := { 
    val original: Seq[Tests.Group] = (testGrouping in Test).value 

    original.map { group => 
    val forkOptions = ForkOptions(
     bootJars = Nil, 
     javaHome = javaHome.value, 
     connectInput = connectInput.value, 
     outputStrategy = outputStrategy.value, 
     runJVMOptions = (javaOptions in Test).value, 
     workingDirectory = Some(baseDirectory.value), 
     envVars = envVars.value 
    ) 

    group.copy(runPolicy = Tests.SubProcess(forkOptions)) 
    } 
}, 
logBuffered in Test := true, 

我怎样才能保持我的测试并行运行,但有输出某种程度上被缓冲和显示顺序,使其可读?是否可能需要在分叉的JVM选项中向outputStrategy提供一些设置?

a similar question here,但我期待让我的测试并行运行。

回答