Code coverage for multi maven module (Sonar + Jacoco + Unit/Integration tests)

424 views
Skip to first unread message

Aurélien Baudet

unread,
Jan 19, 2016, 11:15:34 AM1/19/16
to SonarQube
Hello,

I have a real project and Sonar doesn't give the real cover. So I tried with this sample and changed it a little to see if it works with the sample. It doesn't seem to work...

The actual sample is very simple:

There is no class and no unit test in app-it.


Here is the test I've done (provided in attachment):

I added one class into app-it that calls code from app. I also added a unit test.


Here are the results in Sonar:


The total number of lines that can be covered = 20 (13 + 7)

The total number of lines covered by unit tests (app + app-it) = 4 (2 + 2)

The total number of lines covered by integration tests (app + app-it) = 10 (7 + 3)

The total number of lines covered by any (app + app-it) = 14 (9 + 5)


So results should be

  • Unit tests: 20% => ok
  • Integration tests: 50% => ko (it counts unit tests of app-it too...)
  • Overall: 70% => ko
Moreover, in the detail views, we only see classes not totally covered (I think it's bad to see only that but it's another problem). Here are the results of detail views:

  • In unit test coverage detail, class HelloWorld3 and module app-it don't appear in the view even if it contains results for unit tests and is not fully covered
  • In integration test coverage detail, the view seems ok. All modules and classes appear but HelloWorld3 coveredByUnitTest method is marked as covered by integration test but should be covered by unit test
  • In overall coverage, only app module appears ! Where is app-it module ???

So my questions:
  • How to configure correctly maven, Sonar and jacoco to have a fully working example ?
  • Then when working, how can I also configure to provide custom jvm memory arguments to failsafe (increase PermGen space) ?


For information, my sonarqube version is 4.5.5. I have tried many solutions found on the internet but none works


Thank you
combined-ut-it-multimodule-maven-jacoco.zip
Reply all
Reply to author
Forward
0 new messages