Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example of an Android build.gradle with configuration for unit and integration testings (Avril 2015)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.0.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'spoon'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
defaultConfig {
applicationId "com.example.jmartinez"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
dependencies {
// BUILD
compile 'com.android.support:appcompat-v7:22.0.0'
// UNIT TESTING
testCompile(
'junit:junit:4.11',
'com.android.support:support-annotations:22.0.0',
'com.squareup.assertj:assertj-android:1.0.0',
'org.mockito:mockito-core:1.9.5',
'org.assertj:assertj-core:1.7.0'
)
testCompile('org.robolectric:robolectric:2.4') {
exclude group: 'commons-logging'
exclude group: 'org.apache.httpcomponents'
}
// INTEGRATION TESTING
configurations {
androidTestCompile.exclude module: 'support-v4'
androidTestCompile.exclude module: 'support-v7'
androidTestCompile.exclude module: 'android'
}
androidTestCompile('com.android.support.test.espresso:espresso-core:2.0',
'com.android.support.test.espresso:espresso-idling-resource:2.0',
'com.android.support.test:testing-support-lib:0.1',
'com.squareup.spoon:spoon-client:1.1.8')
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.0') {
exclude group: 'com.android.support', module: 'support-annotations'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.