Introduce run-mutation-tests.sh (#170)

This script executes Pitest to determine the code base' mutation test coverage.
The set of tests executed can optionally be restricted by name. The results are 
found in each Maven module's `target/pit-reports` directory.
This commit is contained in:
Stephan Schroevers
2022-08-09 14:38:19 +02:00
committed by GitHub
parent 12b03e95b1
commit c57653dd5b
2 changed files with 27 additions and 2 deletions

View File

@@ -73,7 +73,8 @@
this 'argLine' property instead of the definition of the 'argLine'
configuration setting allows users or plugins to specify additional
arguments. In particular, JaCoCo relies on this for the configuration
of its Java agent. -->
of its Java agent, and Pitest uses this configuration when it spawns
additional JVMs. -->
<argLine>
<!-- The JVM arguments specified in `.mvn/jvm.config` also apply to
test JVMs, as those are also non-interactive processess running
@@ -99,7 +100,7 @@
<!-- We cap memory usage. This may be relevant for build agents,
but also prevents excessive memory usage by heavily parallelized
local builds. -->
-Xmx1024m
-Xmx${argLine.xmx}
<!-- This argument cannot be set through Surefire's
'systemPropertyVariables' configuration setting. Setting the file
encoding is necessary because forked unit test invocations
@@ -118,6 +119,9 @@
from showing up in the dock and capturing window focus. -->
-Djava.awt.headless=true
</argLine>
<!-- The maximum amount of heap memory available to forked Surefire
processes. Factored out into a separate property to allow overriding. -->
<argLine.xmx>1024m</argLine.xmx>
<!-- Our build system provides a monotonically increasing build number.
When building locally, this number is obviously absent. So we provide a
default value. -->

21
run-mutation-tests.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Executes Pitest to determine the code base' mutation test coverage. The set
# of tests executed can optionally be restricted by name. The results are found
# in each Maven module's `target/pit-reports` directory.
set -e -u -o pipefail
if [ "${#}" -gt 1 ]; then
echo "Usage: ./$(basename "${0}") [TargetTests]"
exit 1
fi
targetTests=${1:-*}
mvn clean test pitest:mutationCoverage \
-DargLine.xmx=2048m \
-Dverification.skip \
-DfailIfNoTests=false \
-Dtest="${targetTests}" \
-DtargetTests="${targetTests}"