I have a long running parameterized test I wish to run asynchronously:
@ParameterizedTest
@MethodSource("createCsvFiles")
@Timeout(30)
void testCsvFiles(Path configFolder) throws Exception {
System.out.println("Running async test for " + configFolder.getFileName() + "...");
doLongRunningOperation().
System.out.println("Async test for " + configFolder.getFileName() + " was run.");
}
I've found guides for general Jupiter tests, it it doesn't seem they work for my use case. I added @Execution(ExecutionMode.CONCURRENT)
to the test class and use this Maven configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<forkCount>4</forkCount>
<reuseForks>true</reuseForks>
<properties>
<configurationParameters>
junit.jupiter.execution.parallel.enabled = true
</configurationParameters>
</properties>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
</plugin>
Yet the log file shows clearly the tests are executed one after the other. I can add junit.jupiter.execution.parallel.mode.default = concurrent
, then all other tests are executed asynchronously (which I don't want).
How do I achieve the same for the parameterized tests and get them to run asynchronously?
question from:
https://stackoverflow.com/questions/66058662/how-to-run-parameterizedtest-asynchronously 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…