szpak / gradle-pitest-plugin

Gradle plugin for PIT Mutation Testing
http://gradle-pitest-plugin.solidsoft.info/
221 stars 58 forks source link

Getting CustomMessageMissingMethodException when configuring gradle-pitest-plugin #222

Closed kellervater closed 4 years ago

kellervater commented 4 years ago

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?

szpak commented 4 years ago

As mentioned in README, please use a fork which is intended for the Android projects only.