Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
162 views
in Technique[技术] by (71.8m points)

java - How to Run @ParameterizedTest Asynchronously

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...