0

I have a Java project with several classes, and I've created junit test cases for each classes.

I've used jacoco plugin to check the unit test coverage of my project using sonarQube 5.5. I'm working on Eclipse Mars 4.5.2 on Windows 7

When I run mvn install using the Eclipse plugin, it reports that a few of my test cases have failed (without any stacktrace as to why), and I see the following exception:

An error has occurred in JaCoCo report generation. Error while creating report: Unknown block type 7.

However, when I run these test cases individually in Eclipse, they work just fine and are successful, meaning that I'm not running mvn install on test cases with incorrect assertions.

I thought that this might be an issue with my Eclipse maven plugin, so I ran mvn install separately using cmd as well, but I get the same exception.

I refreshed my project in Eclipse. All my test cases pass after that (strangely), but I still see this exception.

What does this exception mean and how can I address it ?

Any guidance will be earnestly appreciated. Thanks

benzonico
  • 10,635
  • 5
  • 42
  • 50
Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39
  • 2
    Did you see https://groups.google.com/forum/#!topic/jacoco/f1ZllnGkjlo which says that parallel test execution is the reason. You must be using surefire plugin. Could you try and run your tests sequentially and see if the problem occurs? – GauravJ Feb 06 '17 at 04:29
  • Yes. I did come across this page, and yes, I'm using surefire plugin. Please tell me how I can serialize the test case run. Thanks – Saransh Kejriwal Feb 06 '17 at 04:35
  • 1
    Please check http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html. More specifically "forkCount=1/reuseForks=false executes each test class in its own JVM process, one after another. It creates the highest level of separation for the test execution, but it would probably also give you the longest execution time of all the available options. Consider it as a last resort." – GauravJ Feb 06 '17 at 04:38
  • Thanks. I'll try that – Saransh Kejriwal Feb 06 '17 at 04:39

1 Answers1

1

This issue is caused due to improper shutdown of a file called jacoco.exec. which is located in the my_project_name/target/ folder.

I solved this issue by going to said folder and deleting jacoco.exec manually and running mvn clean install via Eclipse again.

Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39