Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Sonar to see Integration Tests (v6.2)

How to visualize Integration Tests in Sonar ?

Currently I only see :

  • the global coverage (UT + IT)
  • the number of UT

enter image description here

I read somewhere we had to configure a widget in the GUI : I didn't see any option which could do that.

Documentation states :

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

But in my case I see that the coverage is changing when I change my UTs (or ITs). Moreover I see jacoco reports in the targets :

  • jacoco.exec
  • jacoco-it.exec

I finaly tryed the official Sonar samples : it is the same ! I didn't find any sample with a clear separation between :

  • Unit test coverage
  • Integration test coverage
  • Overall test coverage

And sorry but Sonar documentation and samples have to be improved...

Context : sonar6.2, java8, spring boot, modular project, maven, surefire & failsafe

like image 762
user2668735 Avatar asked Jan 21 '17 23:01

user2668735


People also ask

How do I get my Maven integration tests to run?

The simplest way to run integration tests is to use the Maven failsafe plugin. By default, the Maven surefire plugin executes unit tests during the test phase, while the failsafe plugin runs integration tests in the integration-test phase.

Does SonarQube run unit tests?

SonarQube doesn't run your tests or generate reports. To include coverage results in your analysis, you need to set up a third-party coverage tool to generate reports and configure SonarQube to import those reports.

Does SonarQube provide test coverage?

SonarQube supports the reporting of test coverage information as part of the analysis of your . NET project. However, SonarQube does not generate the coverage report itself. Instead, you must set up a third-party tool to produce the report as part of your build process.


Video Answer


2 Answers

Starting in SonarQube 6.2, all test results are merged into simply "coverage". This was done on the theory that by and large, most people don't care how their code is covered, only that it is covered.

With this change, some math inconsistencies w/r/t how Overall Coverage was calculated from unit tests versus integration tests were eliminated, and additionally the ability to feed many different coverage reports was added. (Some people have unit, integration, smoke, ... tests).

Regarding

I read somewhere we had to configure a widget in the GUI : I didn't see any option which could do that.

In 6.2 dashboards were dropped, so there are no widgets to be configured. Coverage is shown automatically on the project home page.

like image 102
G. Ann - SonarSource Team Avatar answered Sep 18 '22 09:09

G. Ann - SonarSource Team


Merging unit testing coverage and integration testing coverage numbers is not a good idea.

Modern unit tests that mock out all dependencies and environmental factors and have been proven to run on a developers local machine cannot by definition fail in a continuous integration environment. This makes them next to useless to run in a CI environment. Therefore, 100% unit test coverage but 0% integration test coverage means no meaningful testing is actually happening in the CI build.

like image 27
Stephen Palmer Avatar answered Sep 21 '22 09:09

Stephen Palmer