Lines-covered="0" though the test cases are success in the Junit report

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube 7.9 and higher version
  • what are you trying to achieve
    Get code coverage through Cobertura
  • what have you tried so far to achieve this
    Did a Cobertura instrumentation, run junit tests (test report generated with all success) and run cobertura report (its created a xml file but hits for the classes, methods as “0” in the file.
    So coverage is not getting generated.

Highly appreciate if any suggestions to fix the problem.

Any solution on this request will be helpful to push the changes to Sonar Qube for the project.

this is happening in windows.

  1. cobertura.ser file is generated with cobertura-instrument
  2. Junit tests ran and tests were successful
  3. coverage.xml file is generated with lines-covered=“0” and coverage shown in sonarqube is also 0.

is there any settings required?

Hi @CodingManager ,

Can you please provide DEBUG logs? Append -X if it’s a Maven project with Sonar Scanner for Maven or append -d if it’s a Gradle project with Sonar Scanner for Gradle (to keep the Gradle logs small, just copy and paste the lines that say org.sonarqube.gradle.SonarQubeTask).


Hi @Joe , thanks for your reply.

I found the problem that i am getting the log saying “cobertura.ser either does not exist or is not readable”

But the file is present in the location. I am using ant build so please suggest any option to handle this issue. I think once the issue is resolved then coverage will come as it is.

Thank you.

when i tried again i was getting like the below, I am running SAP platform FYI…

[yunitint] Unable to get lock channel for D:\ProjectmyWorkspacesonar arget
[yunitint] eportscobertura-reportcobertura.ser.lock: D:\ProjectmyWorkspacesonar argeteportscobertura-reportcobertura.ser.lock (The filename, directory name, or volume label syntax is incorrect)lock file could not be deleted
[yunitint] INFO [Thread-1] [DefaultClusterNodeManagementService] Unregistering assigned cluster node id 0…

Hi @CodingManager,

Can you post the entire console debug logs? It looks like some of the back slashes/forward slashes are getting removed and the error seems to be missing some context.

Yes @Joe . slashes are getting remove some reason but not sure why / how. There is no much information in the log files as well. When i run the unit test on top of instrumentation file, system is taking the dir and appending that with cobertura. Is there any settings for this to remove?

Hi @CodingManager ,

Can you please post the entire debug logs for your build: ant sonar -v? I’m not a cobertura expert but I’ll see what I can do once you provide the entire set of logs.

Also, how are you invoking cobertura or how do you run the unit tests?