Jacoco report coverage when using Mockito showing zero in Sonar

3,002 views
Skip to first unread message

Niki Eskola

unread,
Jun 28, 2017, 6:30:59 AM6/28/17
to SonarQube

Hi,

we are building our project with maven 3.3.9 with following relevant plugins/libraries.

Spring Boot 1.5.3.RELEASE
Jacoco 0.7.9
Mockito 2.8.47
Sonar Maven Plugin 3.3.0.603

SonarQube Version 6.4 (build 25310)
SonarJava 4.10.0.10260

Our problem: jacoco coverage report shows ok coverage for code branch which is mocked in junit test with mockito. However Sonar shows 0% coverage of the same branch.
Coverage values of all other tests which aren't mocked are equal.

Our jacoco.exec file is produced to target/coverage-reports and is found correctly with Sonar plugin.

Test, jacoco and sonar report output.







jacoco.exec

Michael Gumowski

unread,
Jun 28, 2017, 7:43:17 AM6/28/17
to Niki Eskola, SonarQube
Hello Niki,

Thanks for your feedback. A few questions:
  • Are all your test files impacted? (not a single file/method marked as covered)
  • Only some methods are marked as not being covered?
  • Could you provide a simple self-contained maven project with a test class relying on mockito and JaCoCo, reproducing the issue systematically?
In order to investigate the issue, we will need a proper reproducer and not only the jacoco.exec report.

Cheers,
Michael

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/67f66845-ddb9-409e-816a-1c9cb2df3d91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Michael Gumowski | SonarSource
Software Developer, Language Team
http://sonarsource.com

Niki Eskola

unread,
Jun 28, 2017, 7:49:12 AM6/28/17
to SonarQube, niki....@veikkaus.fi
Hi Michael and thanks for your response.

In this project other test cases which are not using mockito are calculated ok and coverage is shown correctly both in jacoco report and sonar web ui.

I'll check if our demo project could reproduce the problem. I'll get back to this soon.

Br,
Niki

Niki Eskola

unread,
Jun 28, 2017, 9:18:21 AM6/28/17
to SonarQube, niki....@veikkaus.fi
Hi Michael,

we failed to reproduce the problem with our java demo project.

We will continue to analyze what's wrong with the actual project and remove functionality.

At the moment it looks that this ain't a Sonar issue. Perhaps something to do with test order.

Br,
Niki

Niki Eskola

unread,
Jun 29, 2017, 7:14:19 AM6/29/17
to SonarQube, niki....@veikkaus.fi
Hi Michael,

this was case sensitivity problem between Jenkins, Bitbucket and Sonar.

Class name under coverage tests was changed with one character with different case and therefore coverage result was set 0% (in other words not found) :)

Br,
Niki
Reply all
Reply to author
Forward
0 new messages