Forked from brettmcginnis/Android Gradle with Custom Test Annotation
Created
June 17, 2016 15:38
-
-
Save venkata-kari/82d81c5f0d34a149882f2fcb9a3c7501 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
repositories { | |
maven { url "http://jzaccone.github.io/SlidingMenu-aar" } | |
} | |
android { | |
compileSdkVersion 22 | |
buildToolsVersion "22.0.1" | |
// jackson jars contain multiple of these so they must be excluded to avoid conflicts | |
packagingOptions { | |
exclude 'META-INF/ASL2.0' | |
exclude 'META-INF/LICENSE' | |
exclude 'META-INF/NOTICE' | |
} | |
defaultConfig { | |
applicationId "com.project" | |
minSdkVersion 14 | |
targetSdkVersion 22 | |
versionCode 21 | |
versionName "3.0.50303" | |
testInstrumentationRunnerArgument "annotation", getTestAnnotation() | |
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | |
} | |
buildTypes { | |
release { | |
minifyEnabled true | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg' | |
} | |
} | |
sourceSets { | |
main { | |
jniLibs.srcDirs = ['libs'] | |
} | |
} | |
} | |
dependencies { | |
androidTestCompile 'com.android.support:support-annotations:22.2.1' | |
androidTestCompile 'com.android.support.test:runner:0.3' | |
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2' | |
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.4.1' | |
} | |
def getTestAnnotation() { | |
def result = "com.test.library.annotation.UnitTest"; | |
if (project.hasProperty("testType")) { | |
result = "com.test.library.annotation." + project.getProperties().get("testType").toString(); | |
} | |
return result; | |
} | |
// Shell tasks to inform dev no how to run different test | |
// These don't actually do anything | |
task unitTest() { | |
group 'Verification' | |
description 'Run "./gradlew connectedAndroidTest -PtestType=UnitTest"' | |
} | |
task uiTest() { | |
group 'Verification' | |
description 'Run "./gradlew connectedAndroidTest -PtestType=UiTest"' | |
} | |
task end2EndTest() { | |
group 'Verification' | |
description 'Run "./gradlew connectedAndroidTest -PtestType=End2EndTest"' | |
} | |
task enduranceTest() { | |
group 'Verification' | |
description 'Run "./gradlew connectedAndroidTest -PtestType=EnduranceTest"' | |
} | |
task integrationTest() { | |
group 'Verification' | |
description 'Run "./gradlew connectedAndroidTest -PtestType=IntegrationTest"' | |
} | |
task loginTest() { | |
group 'Verification' | |
description 'Run "./gradlew connectedAndroidTest -PtestType=LoginTest"' | |
} | |
task longHaulTest() { | |
group 'Verification' | |
description 'Run "./gradlew connectedAndroidTest -PtestType=LongHaulTest"' | |
} | |
task smokeTest() { | |
group 'Verification' | |
description 'Run "./gradlew connectedAndroidTest -PtestType=SmokeTest"' | |
} | |
task testBoxTest() { | |
group 'Verification' | |
description 'Run "./gradlew connectedAndroidTest -PtestType=TestBoxTest"' | |
} | |
task testInfrastructureTool() { | |
group 'Verification' | |
description 'Run "./gradlew connectedAndroidTest -PtestType=TestInfrastructureTool"' | |
} | |
// Requried for Continous Integration | |
// The gradle process will always pass even with test failures | |
// inspect test results app/build/outputs/androidTest-results/connected/ | |
project.gradle.taskGraph.whenReady { | |
//println(project.gradle.taskGraph.allTasks) | |
connectedDebugAndroidTest { | |
ignoreFailures = true | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment