Created
August 6, 2019 10:52
-
-
Save ivarprudnikov/a90093255f055472905b395fa93aefb6 to your computer and use it in GitHub Desktop.
Enabling Android instrumentaiton tests on Travis CI. This was not working at the time due to Travis not being able to boot up emulator or similar.
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
language: android | |
sudo: required | |
jdk: openjdk8 | |
android: | |
components: | |
# https://github.com/travis-ci/travis-ci/issues/5036 | |
- tools | |
# The BuildTools version used by your project | |
- build-tools-28.0.3 | |
# The SDK version used to compile your project | |
- android-28 | |
# Additional components | |
- extra-google-m2repository | |
- extra-android-m2repository | |
before_install: | |
# Get rid of warning | |
- touch $HOME/.android/repositories.cfg | |
# Accept licences | |
- echo yes | sdkmanager --update > /dev/null | |
- echo yes | sdkmanager --licenses > /dev/null | |
# Install the rest of tools (e.g., avdmanager). | |
- echo yes | sdkmanager tools > /dev/null | |
# Update emulator | |
- echo yes | sdkmanager 'emulator' > /dev/null | |
# Install the system image. | |
- echo yes | sdkmanager "system-images;android-24;default;armeabi-v7a" > /dev/null | |
# Create and start emulator for the script. Meant to race the install task. | |
- echo no | avdmanager create avd --force -n emulatorname -k "system-images;android-24;default;armeabi-v7a" | |
- $ANDROID_HOME/emulator/emulator -memory 1024 -avd emulatorname -skin 768x1280 -no-boot-anim -no-audio -no-window -no-snapshot -no-snapstorage -no-cache & | |
before_script: | |
- echo 'org.gradle.jvmargs=-Xms4g -Xmx4g -XX:+HeapDumpOnOutOfMemoryError' >> gradle.properties | |
- android-wait-for-emulator | |
- adb shell settings put global window_animation_scale 0 & | |
- adb shell settings put global transition_animation_scale 0 & | |
- adb shell settings put global animator_duration_scale 0 & | |
- adb shell input keyevent 82 & | |
script: ./gradlew runTests --build-cache --stacktrace |
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' | |
android { | |
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_1_8 | |
targetCompatibility JavaVersion.VERSION_1_8 | |
} | |
compileSdkVersion 28 | |
buildToolsVersion '28.0.3' | |
defaultConfig { | |
applicationId "com.mypackage.foobar" | |
minSdkVersion 24 | |
targetSdkVersion 28 | |
versionCode 127 | |
versionName "127" | |
multiDexEnabled true | |
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | |
} | |
packagingOptions { | |
exclude 'META-INF/androidx.exifinterface_exifinterface.version' | |
exclude 'META-INF/proguard/androidx-annotations.pro' | |
} | |
buildTypes { | |
debug {} | |
release {} | |
} | |
testOptions { | |
unitTests.returnDefaultValues = true | |
} | |
// Specifies flavor dimensions. | |
flavorDimensions "tier" // if only one then no need to specify under each flavour | |
productFlavors { | |
demo { | |
// dimension "tier" // optional if only one dimension | |
} | |
} | |
} | |
repositories { | |
// .... | |
} | |
dependencies { | |
// .... | |
// unit tests | |
testImplementation 'junit:junit:4.12' | |
testImplementation 'pl.pragmatists:JUnitParams:1.1.1' | |
testImplementation 'org.hamcrest:hamcrest-library:1.3' | |
testImplementation 'org.mockito:mockito-core:2.23.0' | |
testImplementation 'com.icegreen:greenmail:1.5.6' | |
// instrumentation tests | |
androidTestImplementation 'org.mockito:mockito-android:2.19.0' | |
androidTestImplementation 'com.android.support:support-annotations:28.0.0' | |
androidTestImplementation 'com.android.support.test:runner:1.0.2' | |
androidTestImplementation 'com.android.support.test:rules:1.0.2' | |
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | |
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3' | |
} | |
task runTests { | |
dependsOn 'testDemoDebugUnitTest', 'connectedDemoDebugAndroidTest' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment