1

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

<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>

I am using the Springboot starter parent

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

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

Andy
  • 5,433
  • 6
  • 31
  • 38
  • Show one of your test classes and also your full pom file ... ... Apart from that I doubt the Maven version cause `3.6.3_1` does not exist... only `3.6.3`... I would suggest to use a more recent version of surefire/failsafe plugin at least 2.22.2 or even better 3.0.0-M4... – khmarbaise Sep 15 '20 at 22:54
  • Sorry about the maven version. It was a typo. I updated the right version in the question. I tried to run with 2.22.2 as well, didn't work. Let me try with the 3.0.0-M5. – Andy Sep 15 '20 at 23:08
  • Please show a test class. Your imports may be wrong. – johanneslink Sep 16 '20 at 05:09
  • I wrote use surefire 3.0.0-M4 not 3.0.0-M5... – khmarbaise Sep 16 '20 at 10:10
  • @khmarbaise : Thanks for your reply. It did not work with both 2.22.2 and 3.0.0-M4. But when I ran it 3.0.0-M5. It works fine. I will post the entire configuration in the answer. Thanks again – Andy Sep 16 '20 at 18:50
  • 1
    @johanneslink The issue was with version incompatibility. I upgraded the surefire version to 3.0.0-M5 to make it work. Thanks a lot for your suggestion. – Andy Sep 16 '20 at 18:51

1 Answers1

1

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

Andy
  • 5,433
  • 6
  • 31
  • 38