Sonarqube not evaluating coverage data for a Java file

I’m working on a microservice. The issue that I’m facing is, while evaluating the code coverage for a particular java file on Sonarqube (the coverage is shown as 0% where the test files exists for the file). Powermock is being used in the test file. Powermock is being used in other files too for which we are able to get the coverage data.
I’m using Jacoco to generate the test reports.
Any help would be appreciated.

Thank you.

hello @Vineet.Salian,

it will be hard to help with just the information you provided. Which version of SonarQube do you use? Which version of sonar-java and sonar-jacoco plugins are installed on your instance? How do you generate your coverage report with JaCoCo? Which scanner do you use (maven, gradle, sonar-scanner)?

Please provide full log of your analysis so we can help you to debug your issue.

Hi Tibor,

The version of Sonarqube is 6.7, I’m also using Powermock org.powermock:powermock-module-junit4:2.0 and org.powermock:powermock-api-easymock:2.0.0.
I won’t be able to share the complete log as there is customer specific data involved.
The error that I get is
Task :service:jacocoTestReport

[ant:jacocoReport] Classes in bundle ‘service’ do no match with execution data. For report generation the same class files must be used as at runtime.

[ant:jacocoReport] Execution data for class com/JavaFileName does not match.

*** It is a gradle project

This error is not about SonarQube, but JaCoCo. There is a known issue with PowerMock and recommended way to fix this is to use offline instrumentation. You can find further details on powemock project wiki