gpt4 book ai didi

junit - 如何并行运行测试但获得整齐有序的测试输出?

转载 作者:行者123 更新时间:2023-12-03 18:03:37 25 4
gpt4 key购买 nike

我正在使用 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,

如何让我的测试并行运行,但以某种方式缓冲和显示输出,以便它可读?是否有一些设置我需要提供给 outputStrategy在 fork 的 JVM 选项中?

a similar question here ,但我希望保持我的测试并行运行。

最佳答案

http://www.scala-sbt.org/1.x/docs/Parallel-Execution.html
parallelExecution in Test控制是否将测试映射到单独的任务。要限制所有项目中同时执行的测试数量,请使用:

concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)

关于junit - 如何并行运行测试但获得整齐有序的测试输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27453882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com