1

When using Cobertura I am able to display unit and integration test coverage separately in Sonar however I can't find a way to display the overall test coverage..

The Sonar documentation implies this is possible using Jacoco but I wondered if it was also possible using Cobertura?

Many thanks

MandyW
  • 1,117
  • 3
  • 14
  • 23

1 Answers1

1

It is not possible, at least not with sonarqube 4.3.

You could however, combine unit-test-coverage generated with cobertura with integration-test-coverage generated with jacoco.

The documentation sais clearly:

"If coverage by unit tests is not computed with JaCoCo, overall coverage = integration test coverage."

You can find the documentation here:

http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project

Sorry and good luck with yout further configuration!

  • Thanks Tim, I am using Cobertura for unit test coverage as I use PowerMockito and Jacoco doesn't report correctly. I can use Jacoco for integration tests (as these don't use PowerMockito) but from your comment and the documentation it then means the unit test coverage is effectively ignored. Is this correct? We really want to enforce that developers get 90% overall test coverage but I can't see any way to do this and support PowerMockito'd tests.. Do you have any other suggestions? – MandyW Jun 01 '14 at 14:39
  • Yes, you´re correct: PowerMockito does not work well with Jacoco and unit test coverage not calculated by Jacoco is effectively ignored in the combined coverage. If you start measuring independent results for unit-tests and integration-tests, you could at least measure the trend. I am sorry I don´t see a better solution at this moment. – TimStefanHauschildt Jun 01 '14 at 14:44
  • Hi Tim, thanks for taking the time to answer.. I'm looking at Jacoco offline instrumentation as an option (to get PowerMockito & Jacoco working together) and have posted http://stackoverflow.com/questions/23983740/unable-to-get-jacoco-to-work-with-powermockito-using-offline-instrumentation as have had some problems getting this to work but hoping it might be an option. – MandyW Jun 01 '14 at 19:44