更新2015年9月7日
這是非常令人沮喪,但我在Android支持庫對特拉維斯CI成功運行了咖啡。這是爲我工作的確切配置。特定的sdk和庫版本號碼很重要,所以不要更改它們,否則會遇到問題。支持註釋的解決策略也是必要的,所以不要刪除。由於Travis CI的Android支持仍處於測試階段,這個答案可能會過時。檢查Travis CI網站的更新here。
.travis.yml
language: android
jdk: openjdk7
android:
components:
- build-tools-22.0.1
- android-20
- extra
- addon
- sys-img-armeabi-v7a-android-19
before_script:
- echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
script:
- ./gradlew connectedAndroidTest
的build.gradle
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
}
}
android {
compileSdkVersion 20
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 20
testApplicationId "com.example.app.test"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:[email protected]'
compile 'com.android.support:support-v4:20.+'
compile 'joda-time:joda-time:2.3'
compile 'com.squareup.retrofit:retrofit:1.4.1'
compile 'com.squareup.retrofit:retrofit-converters:1.9.0'
compile 'com.squareup.retrofit:retrofit-mock:1.4.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.3.1'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.3.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.1'
compile 'com.google.guava:guava:16.0'
androidTestCompile 'com.android.support:support-annotations:20.+'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.squareup:fest-android:1.0.7'
}
configurations.all {
resolutionStrategy {
// fail eagerly on version conflict (includes transitive dependencies)
// e.g. multiple different versions of the same dependency (group and name are equal)
failOnVersionConflict()
// force certain versions of dependencies (including transitive)
// *append new forced modules:
force 'com.android.support:support-annotations:20.+', 'com.squareup.retrofit:retrofit:1.4.1'
// *replace existing forced modules with new ones:
forcedModules = ['com.android.support:support-annotations:20.+', 'com.squareup.retrofit:retrofit:1.4.1']
// cache dynamic versions for 10 minutes
cacheDynamicVersionsFor 10*60, 'seconds'
// don't cache changing modules at all
cacheChangingModulesFor 0, 'seconds'
}
}
PerformException: Error performing 'single click' on view
將此代碼添加到測試:
closeSoftKeyboard();
Thread.sleep(1000);
例
public void testThatSuccessDialogIsShownWithValidCardInput() throws Exception {
onView(withId(R.id.card_number))
.perform(typeText("4242424242424242"));
closeSoftKeyboard();
Thread.sleep(1000);
onView(withId(R.id.card_exp_month))
.perform(typeText("01"));
onView(withId(R.id.card_exp_year))
.perform(typeText("20"));
onView(withId(R.id.card_cvc_code))
.perform(typeText("313"));
closeSoftKeyboard();
Thread.sleep(1000);
onView(withText("Submit"))
.perform(click());
onView(withText("Success!"))
.check(matches(isDisplayed()));
onView(withText("OK"))
.perform(click());
onView(withText("OK"))
.check(doesNotExist());
}
工作項目
https://travis-ci.org/Kurry/Venmo-Android-Coding-Challenge
https://github.com/Kurry/Venmo-Android-Coding-Challenge