Skip to content

Commit 6f681be

Browse files
authored
#239: Add test coverage (#272)
* Fixed #239: add jacoco for test coverage - remove no more needed clover configuration * #239: add codecov action
1 parent 079f87a commit 6f681be

File tree

2 files changed

+32
-42
lines changed

2 files changed

+32
-42
lines changed

.github/workflows/maven.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,11 @@ jobs:
8686

8787
- name: Spotbugs check
8888
run: mvn --batch-mode --errors verify --file pom.xml '-Pspotbugs'
89+
90+
- name: JaCoCo report
91+
run: mvn --batch-mode --errors jacoco:report --file pom.xml
92+
93+
- name: Codecov
94+
uses: codecov/codecov-action@v1
95+
with:
96+
files: target/site/jacoco/jacoco.xml

pom.xml

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@
3030
<wagon.version>2.2</wagon.version>
3131
<gmaven.provider.selection>2.0</gmaven.provider.selection>
3232
<groovy.version>3.0.7</groovy.version>
33-
34-
<clover.version>3.3.0</clover.version>
35-
<clover.license>/private/reficio/clover.license</clover.license>
33+
<jacoco.version>0.8.7</jacoco.version>
3634
</properties>
3735

3836
<licenses>
@@ -362,6 +360,9 @@
362360
<executions>
363361
<execution>
364362
<goals>
363+
<goal>addSources</goal> <!-- important for jacoco that it recognizes to measure the coverage of classes in src/main/groovy-->
364+
<goal>addTestSources</goal> <!-- important for jacoco that it recognizes to use tests in src/test/groovy for coverage measuring-->
365+
<goal>compile</goal>
365366
<goal>generateStubs</goal>
366367
<goal>compile</goal>
367368
<goal>generateTestStubs</goal>
@@ -401,6 +402,18 @@
401402
</excludes>
402403
</configuration>
403404
</plugin>
405+
<plugin>
406+
<groupId>org.jacoco</groupId>
407+
<artifactId>jacoco-maven-plugin</artifactId>
408+
<version>${jacoco.version}</version>
409+
<executions>
410+
<execution>
411+
<goals>
412+
<goal>prepare-agent</goal> <!-- add javaagent to surefire's test run -->
413+
</goals>
414+
</execution>
415+
</executions>
416+
</plugin>
404417
<plugin>
405418
<groupId>com.mycila</groupId>
406419
<artifactId>license-maven-plugin</artifactId>
@@ -419,7 +432,6 @@
419432
<excludes>
420433
<exclude>target/**</exclude>
421434
<exclude>**/resources/**</exclude>
422-
<exclude>.clover/**</exclude>
423435
<exclude>.dependabot/**</exclude>
424436
</excludes>
425437
<useDefaultExcludes>true</useDefaultExcludes>
@@ -602,32 +614,6 @@
602614
</build>
603615
</profile>
604616

605-
<profile>
606-
<id>clover</id>
607-
<build>
608-
<plugins>
609-
<plugin>
610-
<groupId>com.atlassian.maven.plugins</groupId>
611-
<artifactId>maven-clover2-plugin</artifactId>
612-
<version>${clover.version}</version>
613-
<executions>
614-
<execution>
615-
<id>clover</id>
616-
</execution>
617-
</executions>
618-
<configuration>
619-
<generateHtml>true</generateHtml>
620-
<generateXml>true</generateXml>
621-
<excludes>
622-
<exclude>**/Logger.java</exclude>
623-
</excludes>
624-
<licenseLocation>${clover.license}</licenseLocation>
625-
</configuration>
626-
</plugin>
627-
</plugins>
628-
</build>
629-
</profile>
630-
631617
<profile>
632618
<id>release</id>
633619
<build>
@@ -683,6 +669,11 @@
683669

684670
<profile>
685671
<id>it</id>
672+
<properties>
673+
<!-- Enable recording of coverage during execution of maven-invoker-plugin -->
674+
<jacoco.propertyName>invoker.mavenOpts</jacoco.propertyName>
675+
<jacoco.includes>org.reficio.p2.*</jacoco.includes>
676+
</properties>
686677
<build>
687678
<plugins>
688679
<plugin>
@@ -711,6 +702,9 @@
711702
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
712703
<preBuildHookScript>setup.groovy</preBuildHookScript>
713704
<postBuildHookScript>validate.groovy</postBuildHookScript>
705+
<extraArtifacts>
706+
<extraArtifact>org.jacoco:org.jacoco.agent:${jacoco.version}:jar:runtime</extraArtifact>
707+
</extraArtifacts>
714708
<scriptVariables>
715709
<originalLocalRepository>${settings.localRepository}</originalLocalRepository>
716710
</scriptVariables>
@@ -807,18 +801,6 @@
807801
</reportSet>
808802
</reportSets>
809803
</plugin>
810-
<plugin>
811-
<groupId>com.atlassian.maven.plugins</groupId>
812-
<artifactId>maven-clover2-plugin</artifactId>
813-
<configuration>
814-
<generateHtml>true</generateHtml>
815-
<generateXml>true</generateXml>
816-
<excludes>
817-
<exclude>**/Logger.java</exclude>
818-
</excludes>
819-
<licenseLocation>${clover.license}</licenseLocation>
820-
</configuration>
821-
</plugin>
822804
</plugins>
823805
</reporting>
824806

0 commit comments

Comments
 (0)