Gradle plugin for PIT Mutation Testing in Android projects
Clone or download
Pull request Compare This branch is 117 commits ahead, 29 commits behind szpak:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
gradle
src
.editorconfig
.gitattributes
.gitignore
CHANGELOG.md
LICENSE-2.0.txt
README.md
appveyor.yml
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Experimental Gradle plugin for PIT Mutation Testing in Android projects

This is a fork of gradle-pitest-plugin which supports Android gradle projects.

Applying plugin in build.gradle

With Gradle plugin portal

plugins {
  id "pl.droidsonroids.pitest" version "0.1.7"
}

With Maven central repository

buildscript {
  repositories {
    mavenCentral()
    google()
    // If you're using a version of Gradle lower than 4.1, you must instead use:
    // maven {
    //     url 'https://maven.google.com'
    // }
    // An alternative URL is 'https://dl.google.com/dl/android/maven2/'    
  }
  dependencies {
    classpath 'pl.droidsonroids.gradle:gradle-pitest-plugin:0.1.7'
  }
}

apply plugin: 'com.android.application'
//or apply plugin: 'com.android.library'
//or apply plugin: 'com.android.test'

apply plugin: 'pl.droidsonroids.pitest'

Usage

pitest<variant> tasks will be created for each build variant (eg. pitestProDebug for pro product flavor and debug build type). Additionally pitest task will run tasks for all variants.

After the measurements a report created by PIT will be placed in ${PROJECT_DIR}/build/reports/pitest/<variant> directory.

For more information see README of source project

Troubleshooting

Tests fail when run under pitest but pass without it

Issue occurs when using Android API without mocking it. Pitest verbose logs may list exceptions like ExceptionInitializerError.

The fastest solution is to set android.testOptions.unitTests.returnDefaultValues = true. See Local unit testing documentation to see other consequences of this change.