From f25de94ae1cb0dc45c2bbe6da68f12a21bb0ed04 Mon Sep 17 00:00:00 2001 From: Hynek Mlnarik Date: Tue, 11 May 2021 08:50:36 +0200 Subject: [PATCH] KEYCLOAK-18070 Report test coverage for model tests --- testsuite/model/pom.xml | 27 +++++++++++++++++++++++++++ testsuite/model/test-all-profiles.sh | 9 +++++++++ 2 files changed, 36 insertions(+) diff --git a/testsuite/model/pom.xml b/testsuite/model/pom.xml index 8bae00ea4b..6198a74926 100644 --- a/testsuite/model/pom.xml +++ b/testsuite/model/pom.xml @@ -24,6 +24,7 @@ h2 ${h2.version} file:${project.build.directory}/dependency/log4j.properties + true disabled @@ -95,10 +96,36 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.7 + + + + prepare-agent + + + true + + org/keycloak/**/* + + + + + report + test + + report + + + + org.apache.maven.plugins maven-surefire-plugin + @{argLine} diff --git a/testsuite/model/test-all-profiles.sh b/testsuite/model/test-all-profiles.sh index b62c458045..532183816a 100755 --- a/testsuite/model/test-all-profiles.sh +++ b/testsuite/model/test-all-profiles.sh @@ -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,([^<]+),)' 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,([^<]+),)' pom.xml`; do grep -A 1 --no-filename '<<<' "target/surefire-reports-$I"/*.txt | perl -pe "print '::error::| $I | ';" done