Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# this is a java project using maven
language: java
# switch off gpg handling
# switch on coverage
install: mvn clean install -D coverage -Dgpg.skip=true
# put the result on codecov.io
after_success:
- bash <(curl -s https://codecov.io/bash)
60 changes: 32 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
# Coverage-Reports mit Maven in Multi-Modul-Projekten
see
- https://blog.doubleslash.de/code-coverage-reports-mit-maven-in-multi-modul-projekten/
- http://wiki.bitplan.com/index.php/Jacoco_maven_multi_module_code_coverage

Beispielkonfiguration für die Generierung von Coverage-Reports in einem Maven-Projekt, das aus mehreren Modulen
besteht. Für Unit-Tests und Integrationstests werden Coverage-Reports erstellt, die jeweils über alle Module
aggregiert sind.
[![Travis (.org)](https://img.shields.io/travis/BITPlan/maven-multimodule-coverage.svg)](https://travis-ci.org/BITPlan/maven-multimodule-coverage)
[![codecov](https://codecov.io/gh/BITPlan/maven-multimodule-coverage/branch/junit-4/graph/badge.svg)](https://codecov.io/gh/BITPlan/maven-multimodule-coverage/branch/junit-4)

Darüber hinaus wird ein Overall-Report erzeugt, der die Gesamt-Testabdeckung beinhaltet (Unit- und
Integrationstests zusammen).
[![BITPlan](http://wiki.bitplan.com/images/wiki/thumb/3/38/BITPlanLogoFontLessTransparent.png/198px-BITPlanLogoFontLessTransparent.png)](http://www.bitplan.com)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the BitPlan logo - as mentioned in separate E-Mail. Thanks!


Für die Messung der Testabdeckung wird das
[JaCoCo-Maven-Plugin](http://www.eclemma.org/jacoco/trunk/doc/maven.html) verwendet.
# Coverage-Reports with Maven in Multi-Modul-Projects

## Laufzeitumgebung ##
This is an example configuration for the generation of coverage reports in a maven project consisting of
multiple modules. Coverage reports are generated for unit and integration tests which are aggregated over all modules.
aggregiert sind.

Erstellt und getestet wurde dieses Projekt mit folgender Laufzeitkonfiguration:
You also get an overall - report showing the total test coverage over unit and integration tests.

- Maven 3.5
- JUnit 4
To measure the test coverage the
[JaCoCo-Maven-Plugin](http://www.eclemma.org/jacoco/trunk/doc/maven.html) is used.

Eine Version dieses Beispiels für JUnit 5 befindet sich
[hier](https://github.com/doubleSlashde/maven-multimodule-coverage/tree/master).
## Enviroment ##
The project was created and tested with the following environment:

## Erstellung der Reports ##
- Maven 3.5
- JUnit 4

Die Reporterzeugung erfolgt automatisch während der Testausführung. Ein über alle Module aggregierter Coverage-Report
für die Unit-Tests wird beim Durchlaufen von Mavens `test`-Phase erzeugt, also z.B. beim Aufruf von `mvn test`.
Another version of this project for JUnit 5 is available in the
[master branch (german)](https://github.com/doubleSlashde/maven-multimodule-coverage/tree/master).

Der Report für die Integrationstests sowie der Gesamtreport werden in der `verify`-Phase generiert, also wenn
z.B. `mvn verify` ausgeführt wird. Dies gilt natürlich auch für den Aufruf von späteren Phasen, denen die Phase `verify`
vorausgeht, also z.B. für `mvn install` oder `mvn deploy`.
## Creation of the reports ##
The reports are automatically created during the test execution. An aggregated report for all modules is
created running the Unit-Tests during maven's `test`-phase, by giving the command `mvn test`.

## Ablageort der Reports ##
The reports for the integration tests and the aggregated report are created during the `verify`-Phase by e.g. starting the `mvn verify` command. This is also true for later phases after `verify`
e.g. `mvn install` or `mvn deploy`.

Die Coverage-Reports (HTML) werden im `site`-Ordner unterhalb von `target` des Moduls `coverage` abgelegt:
- `coverage/target/site/jacoco-aggregate-ut/index.html`: Coverage-Report der Unit-Tests
- `coverage/target/site/jacoco-aggregate-it/index.html`: Coverage-Report der Integrationtests
- `coverage/target/site/jacoco-aggregate-all/index.html`: Kumulierter Gesamtreport der Unit- und Integrationstests
## Storagepath for Reports ##

## Wichtig! ##
The Coverage-Reports (HTML) are located in the `site`-folder as a subfolder of `target` of the module `coverage`:
- `coverage/target/site/jacoco-aggregate-ut/index.html`: Coverage-Report of Unit-Tests
- `coverage/target/site/jacoco-aggregate-it/index.html`: Coverage-Report of Integrationtests
- `coverage/target/site/jacoco-aggregate-all/index.html`: Aggregated Totalreport of Unit- and Integrationstests

Wird dem Projekt ein neues Modul hinzugefügt, muss dieses in der `pom.xml` des `coverage`-Moduls als Dependency
hinzugefügt werden. _Ansonsten wird die Testabdeckung des neuen Moduls in den aggregierten Reports nicht berücksichtigt_!
## Important when adding modules! ##
The modules you'd like to get reports for needed to be declared as dependencies in the `pom.xml` of the `coverage`-Module.
Otherwise the module's coverage report will not be integrated into the aggregated report.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<version>0.8.4</version>
</plugin>
</plugins>

Expand Down