KEYCLOAK-18070 Report test coverage for model tests

This commit is contained in:
Hynek Mlnarik 2021-05-11 08:50:36 +02:00 committed by Hynek Mlnařík
parent 2539bd9ed3
commit f25de94ae1
2 changed files with 36 additions and 0 deletions

View file

@ -24,6 +24,7 @@
<jdbc.mvn.artifactId>h2</jdbc.mvn.artifactId>
<jdbc.mvn.version>${h2.version}</jdbc.mvn.version>
<log4j.configuration>file:${project.build.directory}/dependency/log4j.properties</log4j.configuration>
<jacoco.skip>true</jacoco.skip>
<keycloak.profile.feature.map_storage>disabled</keycloak.profile.feature.map_storage>
</properties>
@ -95,10 +96,36 @@
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>true</append>
<includes>
<include>org/keycloak/**/*</include>
</includes>
</configuration>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine}</argLine>
<systemPropertyVariables>
<!-- keycloak.model.parameters lists parameter classes from
org.keycloak.model.parameters package and determine enabled providers -->

View file

@ -1,5 +1,11 @@
#!/bin/bash
##
## To include test coverage data, use -Djacoco.skip=false parameter.
## This will gather the coverage data into target/jacoco.exec file and
## generate the coverage report for each module in keycloak/model/*/target/site.
##
cd "$(dirname $0)"
mvn -version
@ -14,6 +20,9 @@ for I in `perl -ne 'print "$1\n" if (m,<id>([^<]+)</id>,)' pom.xml`; do
mv target/surefire-reports "target/surefire-reports-$I"
done
## If the jacoco file is present, generate reports in each of the model projects
[ -f target/jacoco.exec ] && mvn -f ../../model org.jacoco:jacoco-maven-plugin:0.8.7:report -Djacoco.dataFile="$(readlink -f target/jacoco.exec)"
for I in `perl -ne 'print "$1\n" if (m,<id>([^<]+)</id>,)' pom.xml`; do
grep -A 1 --no-filename '<<<' "target/surefire-reports-$I"/*.txt | perl -pe "print '::error::| $I | ';"
done