Difference between revisions of "Sonar + maven principle"
(Created page with "Category:Development Category:Linux SonarQube requires quite some configuration to be fully useful! This article explains '''how to configure your maven projects'''...") |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
SonarQube requires quite some configuration to be fully useful! | SonarQube requires quite some configuration to be fully useful! | ||
− | This article explains | + | This article explains the key principles + what is UNIT and INTEGRATION tests from my point of view. |
Line 28: | Line 28: | ||
Definition: | Definition: | ||
− | * '''Unit Tests coverage (UT)''' | + | * '''Unit Tests coverage (UT)''' |
− | |||
+ | = code coverage for each module only. | ||
− | + | == How much tests of 'module A' test 'module A' ?? | |
− | |||
− | |||
− | + | ||
− | + | * '''Integration Tests coverage (IT)''' | |
+ | |||
+ | = overall code coverage. | ||
+ | |||
+ | == Once global compilation and all the tests have been run, how much of 'module A' was used and covered ? | ||
Line 50: | Line 52: | ||
** Maven-surefire (unit tests reports) | ** Maven-surefire (unit tests reports) | ||
** Maven-failsafe (integration tests reports) | ** Maven-failsafe (integration tests reports) | ||
− | |||
Line 56: | Line 57: | ||
* SONAR is configured for ''JAVA'' language and it will use ''Jacoco'' as coverage tool. | * SONAR is configured for ''JAVA'' language and it will use ''Jacoco'' as coverage tool. | ||
* Each Maven module will have its own Unit Tests results (Surefire reports + .exec file) inside its own <code>target</code> directory | * Each Maven module will have its own Unit Tests results (Surefire reports + .exec file) inside its own <code>target</code> directory | ||
− | * The Integration Tests results are common. Meaning | + | * The Integration Tests results are common. Meaning: |
− | + | ** all modules will write in the same directory | |
− | + | ** That directory is relative to the maven execution | |
− | + | ** All reports will be aggregated | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | * | ||
− | |||
− | |||
− | |||
− | * | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 10:59, 12 April 2019
SonarQube requires quite some configuration to be fully useful!
This article explains the key principles + what is UNIT and INTEGRATION tests from my point of view.
Principle
What are Unit / Integration tests ?
By default "code coverage" only consider the tests from the same projects.
Let's take an example to make things easier...
Consider a project with 4 modules such as:
Then consider the following inter-dependencies:
Definition:
- Unit Tests coverage (UT)
= code coverage for each module only.
== How much tests of 'module A' test 'module A' ??
- Integration Tests coverage (IT)
= overall code coverage.
== Once global compilation and all the tests have been run, how much of 'module A' was used and covered ?
Process overview
To work well SonarQube requires a bit of Maven configuration + Jenkins build adjustment:
- Maven specific properties
- Maven build plug-ins
- Maven-jacoco (code coverage tool)
- Maven-surefire (unit tests reports)
- Maven-failsafe (integration tests reports)
Key points:
- SONAR is configured for JAVA language and it will use Jacoco as coverage tool.
- Each Maven module will have its own Unit Tests results (Surefire reports + .exec file) inside its own
target
directory - The Integration Tests results are common. Meaning:
- all modules will write in the same directory
- That directory is relative to the maven execution
- All reports will be aggregated