I'm trying to include mutation testing for my Android local UnitTests. I found https://pitest.org/ framework which I tried to include using the "officially" recommended gradle plugin from here: https://gradle-pitest-plugin.solidsoft.info/
Gradle Wrapper version: 6.5.1
But I can't figure out how to get it up and running. The docs on the plugins webpage are very fragmented and so I don't know if my gradle configuration is even correct.
My build.gradle
file:
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.5.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My build.gradle (app)
file:
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'info.solidsoft.pitest'
android { ... }
dependencies { ... }
pitest {
targetClasses = ['training.your.app.data.viewmodel.*']
pitestVersion = '1.5.1'
threads = 4
outputFormats = ['XML', 'HTML']
timestampedReports = false
}
With this approach the IDE (AndroidStudio 4) gradle sync tells me:
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method pitest() for arguments [build_w05scwyltsg8pepn5z5mp7e1$_run_closure3@651693d3] on project ':app' of type org.gradle.api.Project.
If I try to do it via gradlew pitest
I get the same result.
My best guess is I'm lacking a lot of gradle knowledge. Any advise?
Thanks to henry's comment I was able to get pitest running with a fork of the gradle-pitest-plugin (https://github.com/koral--/gradle-pitest-plugin).
Long story short:
build.gradle
build.gradle (app)
This won't work with Gradle version
6.5.1
. The author of this plugin claims to have this issue fixed with the plugin version0.2.4
. But this version hasn't been published to maven central yet.So use Gradle
6.3
withpl.droidsonroids.gradle:gradle-pitest-plugin:0.2.2
and you're good to go.