Skip to content

Commit 79374eb

Browse files
author
Adrian Clay
authored
Introduce Mutation Testing quality check GitHub Action (#790)
* Introduce Mutation Testing quality check GitHub Action This workflow will identify code within a PR which isn't fully covered with tests using a process called Mutation testing. This process isn't perfect, but hopefully the feedback it does identify can start a conversation about where tests are missing. * Remove config folder which crashes pitest The pitest git integration tries to automatically find the git repo root directory. In doing so, the presence of a directory called config causes it to crash.
1 parent 71555f8 commit 79374eb

File tree

6 files changed

+55
-1
lines changed

6 files changed

+55
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Mutation Testing
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
pitest:
7+
# Only run on PRs from the repo. PRs from forks will fail due to lack of permissions and
8+
# must use a two stage process
9+
if: github.event.pull_request.head.repo.full_name == github.repository
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout project
13+
uses: actions/checkout@v4
14+
with:
15+
# important to set a fetch depth of 2. By default the checkout action make no history available
16+
fetch-depth: 2
17+
- name: Setup Java JDK
18+
uses: actions/[email protected]
19+
with:
20+
distribution: 'temurin'
21+
java-version: 21
22+
- name: run pitest
23+
working-directory: ./service
24+
run: ./gradlew pitest-github
25+
env:
26+
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}

arcmutate-licence.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Licence file for pitest extensions
2+
#Tue Jul 16 09:22:03 BST 2024
3+
expires=16/07/2026
4+
keyVersion=1
5+
packages=uk.nhs.adaptors.*
6+
signature=LGGLekLoKiQ4JOPs2iLFzr9Xm62elcZHhKwOAtcxXlU5ofB+aoEpRkSuQt/VH0kYi44eqeAGnkcrZ2knY5OMwu2YYUxySXb+J1IXvxLpQwXNy0L7DZuTz85w6RecvyfKXIYXD/DrS3gfq+o3jwCrWGqYYajVuwl5Q3ZqFGVYk1w\=
7+
type=OSSS

service/build.gradle

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ plugins {
66
id "com.github.spotbugs" version "6.0.20"
77
id "io.freefair.lombok" version "8.6"
88
id 'jacoco'
9+
10+
// Mutation testing
11+
id 'info.solidsoft.pitest' version '1.15.0'
12+
id 'com.arcmutate.github' version '1.2.1'
913
}
1014

1115
apply plugin: 'java'
@@ -21,6 +25,7 @@ sourceCompatibility = '21'
2125

2226
checkstyle {
2327
toolVersion '8.38'
28+
configDirectory = 'checkstyle' as File
2429
}
2530

2631
repositories {
@@ -66,6 +71,9 @@ dependencies {
6671
testImplementation 'org.wiremock:wiremock-standalone:3.9.1'
6772
testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
6873
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
74+
75+
pitest 'com.arcmutate:base:1.3.1'
76+
pitest 'com.arcmutate:pitest-git-plugin:1.3.2'
6977
}
7078

7179
test {
@@ -132,10 +140,23 @@ spotbugsMain {
132140
xml {
133141
enabled = true
134142
}
135-
excludeFilter.set(file("config/spotbugs/exclude.xml"))
143+
excludeFilter.set(file("spotbugs/exclude.xml"))
136144
}
137145
}
138146

147+
pitest {
148+
pitestVersion = '1.16.1'
149+
junit5PluginVersion = '1.2.1'
150+
outputFormats = ['gitci']
151+
152+
// git feature limits analysis to contents of PR only
153+
features = ["+GIT(from[HEAD~1])"]
154+
155+
mutators = ['STRONGER', 'EXTENDED_ALL']
156+
157+
threads = project.getGradle().getStartParameter().getMaxWorkerCount()
158+
}
159+
139160
bootJar {
140161
exclude("**/TransformJsonToXml*")
141162
}
File renamed without changes.

0 commit comments

Comments
 (0)