运行 并行的 junit 参数化测试(不是 类)
Running junit parameterized tests (not classes) in parallel
我有一个参数化的 junit 集成测试。它有 30 个输入(给它 30 个测试 运行),每个需要 18 秒。
我想运行他们并行。
我 运行从 gradle 中提取它们,它们目前是用 jUnit4 编写的,但如果有帮助,我准备切换到 jUnit5。
目前我可以使用 gradles maxParallelForks
但那只能在 类.
上分叉
JUnit 5 built-in 支持 运行 并行测试。官方文档无疑是检查它的最佳来源:
https://junit.org/junit5/docs/snapshot/user-guide/#writing-tests-parallel-execution
该功能从 v 5.3 开始可用
创建src/test/resources/junit-platform.properties,内容如下:
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.default
将 运行 并行测试同一 class 中的方法(包括参数化方法)。
还有来自多个 class 并行的 junit.jupiter.execution.parallel.mode.classes.default
到 运行 测试。查看 jUnit 5 docs 中的图片,了解 2 个属性之间的区别。
我有一个参数化的 junit 集成测试。它有 30 个输入(给它 30 个测试 运行),每个需要 18 秒。
我想运行他们并行。
我 运行从 gradle 中提取它们,它们目前是用 jUnit4 编写的,但如果有帮助,我准备切换到 jUnit5。
目前我可以使用 gradles maxParallelForks
但那只能在 类.
JUnit 5 built-in 支持 运行 并行测试。官方文档无疑是检查它的最佳来源: https://junit.org/junit5/docs/snapshot/user-guide/#writing-tests-parallel-execution
该功能从 v 5.3 开始可用
创建src/test/resources/junit-platform.properties,内容如下:
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.default
将 运行 并行测试同一 class 中的方法(包括参数化方法)。
还有来自多个 class 并行的 junit.jupiter.execution.parallel.mode.classes.default
到 运行 测试。查看 jUnit 5 docs 中的图片,了解 2 个属性之间的区别。