使用jUnit5 @ParameterizedTest和csvSource进行并行测试

时间:2019-09-05 15:22:57

标签: junit parallel-processing junit5

我发现Junit5自5.3版以来就支持并行性,但是我找不到任何有关如何使用csv源运行并行测试的参考。你有什么建议吗?

2 个答案:

答案 0 :(得分:1)

或者,您可以创建具有相同内容的src/test/resources/junit-platform.properties

junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = concurrent

答案 1 :(得分:0)

按照以下步骤配置故障安全插件

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.22.2</version>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
    <!--override configuration from parent pom-->
    <configuration combine.self="override">
        <properties>
            <configurationParameters>
                junit.jupiter.execution.parallel.enabled = true
                junit.jupiter.execution.parallel.mode.default = concurrent
                junit.jupiter.execution.parallel.mode.classes.default =concurrent
            </configurationParameters>
        </properties>
    </configuration>
</plugin>

如此处https://junit.org/junit5/docs/snapshot/user-guide/#writing-tests-parallel-execution所述。这也适用于参数化测试