maven - maven-surefire-plugin 在 SpringBoot 2.2.2.RELEASE 及更高版本中不起作用
问题描述
我在我的 Maven 项目中使用了 maven-surefire-plugin 来并行执行测试。一切都很好。当我升级到 SpringBoot 2.2.2.RELEASE 及更高版本时,测试停止并行运行。这就是我使用插件的方式:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</plugin>
有没有办法并行执行测试?用这个插件?
我上传了一个包含两个模块的小型 Maven 项目:
- springBoot 2.2.6.RELEASE 的不工作模块
- springBoot 1.5.9.RELEASE 的工作模块
除了 SprintBoot 版本之外,这两个模块都是相同的
解决方案
在 pom 中创建配置:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-jupiter</artifactId>
<groupId>org.junit.jupiter</groupId>
</exclusion>
<exclusion>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.junit.vintage</groupId>
</exclusion>
<exclusion>
<artifactId>mockito-junit-jupiter</artifactId>
<groupId>org.mockito</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
</dependency>
这里的问题当然是您只使用 JUnit 4。
推荐阅读
- java - 使用 Java 进行金字塔打印
- javascript - Vue中单击元素后的事件
- html - materializecss:如何让图像留在列中
- crystal-reports - SAP Business Objects - 每个报表的列表及其用户访问权限
- swift - 快速滚动后 didDeselectItemAt 不起作用
- java - 如果以前的网页没有在 WEB VIEW 中加载,如何将其更改为我自己的网页?
- javascript - 防止重复提交
- html - 激活时更改菜单背景颜色
- javascript - Internet Explorer canvas.toDataURL SecurityError
- java - 有人熟悉 Leetcode 上的“二叉树的直径”问题吗?