我正在使用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,但我希望我的测试能够并行运行。
答案 0 :(得分:-1)
请参阅http://www.scala-sbt.org/1.x/docs/Parallel-Execution.html
parallelExecution in Test
控制测试是否映射到单独的任务。要限制所有项目中并发执行测试的数量,请使用:
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)