summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-09-29 10:52:07 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-10-02 12:14:28 +0200
commitc242de2e9d47102f99b754afc8cdff7a2a517843 (patch)
tree8194fcb4fe1dc4919d919b15ea4367dbee4a2d68
parent40bcf70a54a277f1391ebb854d9d2b879ca07a27 (diff)
Include IT coverage in JaCoCo and Sonar reports
* introduces jacoco-it.exec which stores aggregated IT test execution data, * configures Sonar to use jacoco-it.exec to report IT coverage, * marks following modules as integration tests: - it-test - minimal-distribution-test - bgp-distribution-test Change-Id: I538c1febb6112a6abad29061f6b00259a0d79f9f Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rw-r--r--common/honeycomb-parent/pom.xml20
-rw-r--r--infra/bgp-distribution-test/pom.xml13
-rw-r--r--infra/it/it-test/pom.xml13
-rw-r--r--infra/minimal-distribution-test/pom.xml13
4 files changed, 57 insertions, 2 deletions
diff --git a/common/honeycomb-parent/pom.xml b/common/honeycomb-parent/pom.xml
index b9831fd87..cc1e5cf8a 100644
--- a/common/honeycomb-parent/pom.xml
+++ b/common/honeycomb-parent/pom.xml
@@ -34,6 +34,13 @@
<!-- Sonar configuration -->
<!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->
<sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**</sonar.exclusions>
+ <!-- https://github.com/SonarSource/sonar-scanning-examples/blob/master/sonarqube-scanner-maven/pom.xml#L24 -->
+ <!-- The destination file for the code coverage report has to be set to the same value
+ in the parent pom and in each module pom. Then JaCoCo will add up information in
+ the same report, so that, it will give the cross-module code coverage. -->
+ <!-- We store jacoco-it.exec in honeycomb-parent because it is built first,
+ so mvn clean won't remove aggregated report. -->
+ <sonar.jacoco.itReportPath>${maven.multiModuleProjectDirectory}/common/honeycomb-parent/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -311,19 +318,28 @@
<version>${jacoco.version}</version>
<executions>
<execution>
- <id>pre-unit-test</id>
+ <id>agent-for-ut</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
- <id>post-unit-test</id>
+ <id>agent-for-it</id>
+ <goals>
+ <goal>prepare-agent-integration</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>jacoco-site</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
<configuration>
+ <!-- Appends data to existing JaCoCo execution file. Required for IT coverage.
+ Will not affect UT which use separate files. -->
+ <append>true</append>
<excludes>
<exclude>**/gen/**</exclude>
<exclude>**/generated-sources/**</exclude>
diff --git a/infra/bgp-distribution-test/pom.xml b/infra/bgp-distribution-test/pom.xml
index e1d4532cc..ec6375a9c 100644
--- a/infra/bgp-distribution-test/pom.xml
+++ b/infra/bgp-distribution-test/pom.xml
@@ -57,4 +57,17 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <!-- Include module's tests in IT coverage report -->
+ <destFile>${sonar.jacoco.itReportPath}</destFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project> \ No newline at end of file
diff --git a/infra/it/it-test/pom.xml b/infra/it/it-test/pom.xml
index acb800481..0ad4c41ca 100644
--- a/infra/it/it-test/pom.xml
+++ b/infra/it/it-test/pom.xml
@@ -70,4 +70,17 @@
<version>${project.version}</version>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <!-- Include module's tests in IT coverage report -->
+ <destFile>${sonar.jacoco.itReportPath}</destFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project> \ No newline at end of file
diff --git a/infra/minimal-distribution-test/pom.xml b/infra/minimal-distribution-test/pom.xml
index ebe7cca89..0ff8ac139 100644
--- a/infra/minimal-distribution-test/pom.xml
+++ b/infra/minimal-distribution-test/pom.xml
@@ -96,4 +96,17 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <!-- Include module's tests in IT coverage report -->
+ <destFile>${sonar.jacoco.itReportPath}</destFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project> \ No newline at end of file