Skip to content

Commit

Permalink
Compute code coverage during Travis CI build
Browse files Browse the repository at this point in the history
The new jacoco Maven profile allows to compute code's coverage
thanks to JaCoCo. It can be used as follows:

 * mvn verify -P jacoco

All reports are aggregated by the org.pitest.pitclipse.tests.coverage.report
module and then sent to CodeCov.
  • Loading branch information
echebbi committed Aug 15, 2019
1 parent a31654d commit da2bede
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage:
status:
patch: off
ignore:
- "**/*Exception.java"
- "**/Activator.java"
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ before_script:
# Prevent installed packages from being used during build
- rm -rfv "$HOME/.m2/repository/org/pitest/"

script: mvn verify
script: mvn verify -P jacoco

after_success:
- bash <(curl -s https://codecov.io/bash)

# Keep p2 information
cache:
Expand Down
68 changes: 68 additions & 0 deletions tests/org.pitest.pitclipse.tests.coverage.report/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.pitest</groupId>
<artifactId>org.pitest.pitclipse.tests</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>org.pitest.pitclipse.tests.coverage.report</artifactId>
<packaging>pom</packaging>

<description>Aggregates Jacoco's code coverage reports, easing their use in CI tools</description>

<profiles>
<profile>
<id>jacoco</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-version}</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>org.pitest.pitclipse.runner</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>org.pitest.pitclipse.runner.tests</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>org.pitest.pitclipse.ui</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>org.pitest.pitclipse.ui.tests</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
38 changes: 38 additions & 0 deletions tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

<!-- Test dependencies -->
<module>io.cucumber</module>

<!-- Global utilities -->
<module>org.pitest.pitclipse.tests.coverage.report</module>
</modules>

<build>
Expand All @@ -40,4 +43,39 @@
</plugin>
</plugins>
</build>

<profiles>
<!-- mvn -Pjacoco to activate code coverage -->
<profile>
<id>jacoco</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-version}</version>
<configuration>
<excludes>
<!-- Ignore Exceptions -->
<exclude>**/*Exception.class</exclude>

<!-- Ignore untestable Activators -->
<exclude>**/Activator.class</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit da2bede

Please sign in to comment.