Skip to content

Instantly share code, notes, and snippets.

@up1
Created March 11, 2015 10:29
Show Gist options
  • Save up1/420c200abe6393d994d1 to your computer and use it in GitHub Desktop.
Save up1/420c200abe6393d994d1 to your computer and use it in GitHub Desktop.
Unit test on Android application
evaluationDependsOn(":app")
apply plugin: 'java'
dependencies {
def androidModule = project(':app')
testCompile project(path: ':app', configuration: 'debugCompile')
def debugVariant = androidModule.android.applicationVariants.find({it.name == 'debug'})
testCompile debugVariant.javaCompile.classpath
testCompile debugVariant.javaCompile.outputs.files
testCompile files(androidModule.plugins.findPlugin("com.android.application").getBootClasspath())
testCompile 'junit:junit:4.+'
testCompile 'org.robolectric:robolectric:2.2'
testCompile 'org.mockito:mockito-core:1.9.5'
}
tasks.withType(Test) {
scanForTestClasses = false
include "**/*Should.class"
include "**/*Test.class"
include "**/*Tests.class"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment