JUnit 5 测试在 IntelliJ 中并行执行,并在本地使用 Maven,但不在 Google Cloud Build 上的 Maven Docker 容器中执行
JUnit 5 tests are executed in parallel inside IntelliJ and locally with Maven, but not inside Maven Docker container on Google Cloud Build
我在我的 Maven 项目中使用 JUnit 5。
我的 junit-platform.properties
看起来像这样:
junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.mode.default=concurrent
当运行在 IntelliJ 内部或本地使用 Maven 测试时,测试是并行执行的。
但是,当 运行在 Maven Docker 容器内的 Cloud Build 上将它们连接时,它们似乎 运行 顺序。
他们是这样称呼的:
steps:
- name: 'maven:3-jdk-11-slim'
args: [
'mvn',
#
'-Dorg.slf4j.simpleLogger.showDateTime=true',
'-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS',
'-B',
'test'
]
它们没有并行执行的原因可能是什么?
Properties such as the desired parallelism and the maximum pool size can be configured using a ParallelExecutionConfigurationStrategy
. The JUnit Platform provides two implementations out of the box: dynamic
and fixed
. Alternatively, you may implement a custom strategy.
请记住,ParallelExecutionConfigurationStrategy class 仍处于 "EXPERIMENTAL" 状态,尚未稳定。可能会发生意外行为。
由于您没有设置特定的配置策略,以下部分适用:
If no configuration strategy is set, JUnit Jupiter uses the dynamic
configuration strategy with a factor of 1. Consequently, the desired parallelism will be equal to the number of available processors/cores.
在 https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution-config
中查找更多详细信息
我在我的 Maven 项目中使用 JUnit 5。
我的 junit-platform.properties
看起来像这样:
junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.mode.default=concurrent
当运行在 IntelliJ 内部或本地使用 Maven 测试时,测试是并行执行的。
但是,当 运行在 Maven Docker 容器内的 Cloud Build 上将它们连接时,它们似乎 运行 顺序。
他们是这样称呼的:
steps:
- name: 'maven:3-jdk-11-slim'
args: [
'mvn',
#
'-Dorg.slf4j.simpleLogger.showDateTime=true',
'-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS',
'-B',
'test'
]
它们没有并行执行的原因可能是什么?
Properties such as the desired parallelism and the maximum pool size can be configured using a
ParallelExecutionConfigurationStrategy
. The JUnit Platform provides two implementations out of the box:dynamic
andfixed
. Alternatively, you may implement a custom strategy.
请记住,ParallelExecutionConfigurationStrategy class 仍处于 "EXPERIMENTAL" 状态,尚未稳定。可能会发生意外行为。
由于您没有设置特定的配置策略,以下部分适用:
If no configuration strategy is set, JUnit Jupiter uses the
dynamic
configuration strategy with a factor of 1. Consequently, the desired parallelism will be equal to the number of available processors/cores.
在 https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution-config
中查找更多详细信息