I'm using sbt and JUnit to run tests for a large Scala project. I'm forking multiple JVMs for tests, and defining how tests should be grouped in the JVMs using testGrouping in Test
.
The tests are running in parallel, but their output is interleaved, making it hard to read through. I have set logBuffered in Test := true
, but that doesn't seem to be doing anything.
Here's a snippet from my 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,
How can I keep my tests running in parallel, but have the output somehow be buffered and displayed in order so that it is readable? Is there perhaps some setting I need to feed to outputStrategy
in the forked JVM options?
There is a similar question here, but I am looking to keep my tests running in parallel.
See http://www.scala-sbt.org/1.x/docs/Parallel-Execution.html
parallelExecution in Test
controls whether tests are mapped to separate tasks. To restrict the number of concurrently executing tests in all projects, use: