Coder Social home page Coder Social logo

davidburstromspotify / gradle-pitest-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from koral--/gradle-pitest-plugin

0.0 1.0 0.0 2.13 MB

Gradle plugin for PIT Mutation Testing in Android projects

License: Apache License 2.0

Groovy 92.65% Java 5.42% Kotlin 1.93%

gradle-pitest-plugin's Introduction

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

plugins {
  id 'pl.droidsonroids.pitest' version '0.2.6'
}
plugins {
  id("pl.droidsonroids.pitest") version "0.2.6"
}

With Maven central repository

buildscript {
  repositories {
    mavenCentral()
    google()
  }
  dependencies {
    classpath "pl.droidsonroids.gradle:gradle-pitest-plugin:0.2.6"
  }
}

plugins {
  id("com.android.application")
  //or id("com.android.library")
  //or id("com.android.test")
  id("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

Robolectric and UnMock

This plugin by default adds mockable Android JAR (generated by Android Gradle Plugin) to classpath used under pitest tests.

If you are using alternative Android framework in tests, like Robolectric or UnMock Gradle Plugin, you may want to add excludeMockableAndroidJar to pitest configuration eg:

pitest {
    targetClasses = ['com.myapp.*']
    excludeMockableAndroidJar = true
}

In such case default mockable Android JAR won't be added and alternative one will be used under tests.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.