【发布时间】:2021-05-16 02:59:43
【问题描述】:
最近得到了一份新工作,我正在从事一个 Maven 和 Micronaut 项目 - 我是 Micronaut 的新手,如果你不熟悉,它是 Spring 的替代品。
以此为指导:https://www.baeldung.com/maven-junit-parallel-tests
我正在尝试让我们的集成测试并行运行,以加快我们的测试速度。我已将所需的配置添加到 pom.xml 文件中。我已经调整了很多,使用不同的设置组合(包括我在其他 SO 帖子中找到的设置)。
但是当我运行测试时,无论有没有这个添加的配置,运行它们所花费的时间是完全相同的 - 1 分 38 秒。所以我认为它不起作用。虽然不知道我在控制台上的预期输出是否正常工作?
在测试中,没有一个使用@RunWith,它使用默认值,应该没问题。
这是pom。有人可以建议吗?谢谢。
<profiles>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>unit, performance</excludedGroups>
<parallel>classes</parallel>
<threadCount>10</threadCount>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>performance</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>unit, integration</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>all</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>none</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<excludedGroups>integration, performance</excludedGroups>
<parallel>classes</parallel>
<threadCount>10</threadCount>
</configuration>
</plugin>
...
</plugins>
</build>
【问题讨论】:
标签: java testing automated-tests maven-3 maven-surefire-plugin