Subscribe Free

Join 2670+ others. No spamming.
I promise!

We are currently under high development. Follow us at github.

Looking for Python Tutorials?
Check these awesome tutorials




Runs your Robolectric Android unit tests. DEPRECATED in favor of , our use of Robolectric was always as a unit testing device, never as some type of integration test Android system test monster. Robolectric is dead, long live the JVM.

If we find time we will merge simple pull requests and make releases, otherwise we recommend moving to Android unit testing ... or if you really have to carry on with Robolectric then fork us.


To run unit tests for your android code:

  • Create a new java module outside the android module that you want to test
  • Apply the android-test plugin to the test module
  • Add your tests under scr/test/java
  • Don't forget to add a dependency from your test module to the android module e.g.
dependencies {
    testCompile 'junit:junit:4.11'
    testCompile 'org.mockito:mockito-core:1.9.5'
    testCompile 'com.squareup:fest-android:1.0.+'
    testCompile 'org.robolectric:robolectric:2.1.+'
  • Last but not least, tell the plugin which is the android module that you want to test
android {
    projectUnderTest ':novoda-app'

Adding to your project

To start using this library, add these lines to the build.gradle of your project:

apply plugin: 'java'
apply plugin: 'android-test'

buildscript {
    repositories {

    dependencies {
        classpath 'com.novoda:gradle-android-test-plugin:0.10.4'

Simple usage

These are the commands you can use once it's all set up:

  • Run ./gradlew test to run all tests
  • Run ./gradlew test{FlavorName} to run tests for a single flavor
  • Run ./gradlew test -Pmatching=**/*TestClassName* to run specific a test class
  • Run ./gradlew test -Pmatching=**/special/**/* to run some tests under a package
  • You can also pass additional JVM params: ./gradlew test -PmaxParallelForks=4 -PmaxHeapSize=4096m -PforkEvery=150 -PtestDebug=true


Here are a list of useful links:

  • We always welcome people to contribute new features or bug fixes, here is how
  • If you have a problem check the Issues Page first to see if we are working on it
  • For further usage or to delve more deeply checkout the Project Wiki
  • Looking for community help, browse the already asked Stack Overflow Questions or use the tag: support-gradle-android-test when posting a new question