- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我目前设置了 Travis-CI,以便在我的 Android 设备的每个版本上运行 gradle ConnectedCheck 任务并执行我的所有单元测试。我已经能够成功设置它。我现在正尝试使用 Espresso 构建一些功能测试,目前我在设置 Travis 时遇到了很多困难,以便我的 espresso 测试可以与 Travis 的模拟器交互。我该如何设置 Travis,使其模拟器的工作方式与我在本地工作站上使用的模拟器完全一样?
这是我用来构建模拟器的 .travis.yml 的一部分。
language: android
jdk: oraclejdk7
env:
matrix:
- ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
android:
components:
- build-tools-20.0.0
- build-tools-19.1.0
before_script:
# Create and start emulator
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
最佳答案
2015 年 9 月 7 日更新
这非常令人沮丧,但我在 Android 支持库中获得了 Espresso,以便在 Travis CI 上成功运行。这是对我有用的确切配置。具体的 sdk 和库版本号很重要,所以不要更改它们,否则会遇到问题。支持注释的解析策略也是必要的,所以也不要删除它。由于 Travis CI 的 android 支持仍处于测试阶段,这个答案可能会过时。查看 Travis CI 网站以获取更新 here .
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
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:4.4.0@aar'
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());
}
关于android - 如何运行 Travis-CI 和 Espresso 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26065596/
在android支持测试库中,为recyclerview编写测试用例时,某些演示使用TypeSafeMatcher,而其他演示则使用BoundedMatcher。谁能解释我为什么在使用示例或用例时使用
我们目前正在为我们的应用程序的一个区域编写 Espresso UI 测试,这需要我们在每次测试后清除应用程序数据 我们之前尝试过使用 Android Orchestrator 我们之前曾尝试使用带有
我已经看到了一些关于它的问题。 例如。 Android Espresso testing app flow 但是上面的答案在espresso 2中不起作用。这是我的摘录 @Rule public Ac
我正在尝试建立一个测试农场,但我发现了一个很大的障碍。手机处于休眠状态时无法运行 Espresso 测试。 android.support.test.espresso.NoActivityResume
我正在运行“gradlew connectedCheck”来在已安装的应用程序上运行 Espresso 测试,但是这个“gradlew connectedCheck”重写了我的应用程序,然后运行测试。
使用 AndroidInjector 和 Subcomponents 无法将作用域对象的事件注入(inject) Espresso 的 Test 类。 以前使用应用程序级组件和事件组件,只要您创建一个
我正在使用Espresso为我的Android应用程序编写UI测试,并想使用MockWebServer模拟HTTP请求。 在运行测试之前,我需要模拟身份验证响应并登录用户。 有没有一种方法可以使应用程
我有一个 ExpandableListView,我想 click() 它的一个 subview 。 我尝试了LOADS OF不同的方法,但我似乎无法理解 Espresso 的工作原理。 例如,为什么这
我目前不熟悉自动化测试和使用 Android Studio 使用 Espresso 执行自动化测试,我正在尝试对登录屏幕执行自动化测试,我目前在执行特定按钮的点击时遇到问题。我尝试了多种按钮方法,但对
Windows 10(64 位), 安卓工作室 3.1.2, Gradle 4.4,Java 1.8。 这是我的布局 xml 这里 @drawable/sign_in_login_bg
Firebase 测试实验室接受 App Bundle/APK 和 android 测试 APK,并且动态功能模块 UI 测试在 Firebase 测试实验室中失败。该错误是关于一些多 dex 问题,
根据我在网络上所做的搜索,我发现很少有人认为 Espresso UI 测试框架不支持 WebViews?是这样吗? 最佳答案 Espresso 支持 WebView,我在下面添加了一个示例 http:
使用 Espresso,我希望能够单击 ExpandableListView(名为 CustomExpandableView)的特定子项。 listview 创建一组RelativeLayouts(名
我有我的 xml 布局: 我想写 Espresso 测试检查 EditText 有android:drawableStart="@drawable/ic_sign_in_password". 我该怎
我正在尝试为 Android 应用程序编写 Espresso 测试,并且需要知道如何自动化使用 AutoCompleteTextView 的部分。下面提到了我的应用程序使用的代码: activity_
我正在尝试为 Android 应用程序编写 Espresso 测试,并且需要知道如何自动化使用 AutoCompleteTextView 的部分。下面提到了我的应用程序使用的代码: activity_
在我的应用中,我使用 Kotlin Flow。在我通过 EspressoIdlingResource.increment() 使用挂起函数之前,它不适用于 Kotlin Flow。如何解决这个问题?
在我的应用中,我使用 Kotlin Flow。在我通过 EspressoIdlingResource.increment() 使用挂起函数之前,它不适用于 Kotlin Flow。如何解决这个问题?
我正在尝试使用 onData 运行 espresso 测试,对于其中只有一个 AdapterView 的 View ,一切正常。但是,当屏幕显示其中嵌套了多个适配器 View 的 View 时,我得到
我想测试是否显示 ID 为 imageViewTour 且标签包含 some_text 的 imageView。 我的测试: onView(allOf(withId(R.id.imageViewTou
我是一名优秀的程序员,十分优秀!