测试在使用Junit 5和Maven时无法运行。

huangapple go评论79阅读模式
英文:

Tests not running with Junit 5 and Maven

问题

我正试图为我的项目运行 Jacoco 测试覆盖率。当我从终端使用命令 mvn clean package 时,测试用例不会运行。但是当我使用 IntelliJ 运行相同的测试时,一切都正常。

我的 Maven 版本是 3.6.3。以下是 pom.xml 中依赖项和插件的版本:

<maven-failsafe-plugin.version>2.22.1</maven-failsafe-plugin.version>
<maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
<jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version>
<junit-jupiter.version>5.7.0</junit-jupiter.version>

我正在使用 Spring Boot Starter Parent:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.1.RELEASE</version>
</parent>

我花了很多时间来尝试找出问题,但没有成功。以下是我尝试过的许多链接中的几个。非常感谢任何帮助。谢谢!

链接 1
链接 2
链接 3

英文:

I am trying to run Jacoco test coverage for my project. When I use the command mvn clean package from the terminal, the test cases won't run. But when I run the same tests using IntelliJ, everything works fine.

My maven version is 3.6.3. These are the versions of the dependencies and plugin in the pom.xml

&lt;maven-failsafe-plugin.version&gt;2.22.1&lt;/maven-failsafe-plugin.version&gt;
&lt;maven-surefire-plugin.version&gt;2.22.1&lt;/maven-surefire-plugin.version&gt;
&lt;jacoco-maven-plugin.version&gt;0.8.5&lt;/jacoco-maven-plugin.version&gt;
&lt;junit-jupiter.version&gt;5.7.0&lt;/junit-jupiter.version&gt;

I am using the Springboot starter parent

 &lt;parent&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
    &lt;version&gt;2.3.1.RELEASE&lt;/version&gt;
 &lt;/parent&gt;

I spent an awful amount of time trying to figure out the issue, but no joy. Below are the few of the many links I tried. Any help is greatly appreciated. Thanks!

Link 1
Link 2
Link 3

答案1

得分: 1

我通过将surefire和failsafe插件的版本从2.22.1更新为3.0.0-M5来解决了这个问题。

英文:

I was able to resolve the issue by updating the version of the surefire and failsafe plugin to 3.0.0-M5 instead of 2.22.1

huangapple
  • 本文由 发表于 2020年9月16日 05:58:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/63910392.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定