Android Espresso 不打算在 android 版本 > 5 上工作
Android Espresso intending not working on android version > 5
我有一个 Espresso UI 测试,它使用 intending 在单击按钮时存根启动新的 activity。
下面的代码在 Android 5.1 及更低版本的设备上运行良好,但在任何 android 版本高于 intending
的设备上似乎无法按照文档中的描述工作。
@Test
public void UnitIshTest() throws Exception {
Instrumentation.ActivityResult result =
new Instrumentation.ActivityResult(Activity.RESULT_OK, new Intent());
intending(hasComponent(TestingController.class.getName())).respondWith(result);
onView(withId(R.id.layout_with_button)).perform(click());
}
基本上我想检查在单击特定按钮时是否触发了意图。但我实际上并不想要启动新 Activity.
的意图
我试图用以下内容替换意图行:intending(isInternal()).respondWith(result);
以捕捉任何可能的意图,但没有成功。
知道如何让相同的功能在 Android 6 和 7 设备上运行吗?
尝试在您的 gradle 文件中进行这些更改
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test:runner:0.3') {
exclude group: 'com.android.support', module: 'support-annotations'
}
我已经在 issue tracker 上创建了一个错误票据,因为 intending 似乎没有按照文档中的描述工作,并且目标 activity 实际上是在具有较新版本 [= 的设备上启动的13=]。
我有一个 Espresso UI 测试,它使用 intending 在单击按钮时存根启动新的 activity。
下面的代码在 Android 5.1 及更低版本的设备上运行良好,但在任何 android 版本高于 intending
的设备上似乎无法按照文档中的描述工作。
@Test
public void UnitIshTest() throws Exception {
Instrumentation.ActivityResult result =
new Instrumentation.ActivityResult(Activity.RESULT_OK, new Intent());
intending(hasComponent(TestingController.class.getName())).respondWith(result);
onView(withId(R.id.layout_with_button)).perform(click());
}
基本上我想检查在单击特定按钮时是否触发了意图。但我实际上并不想要启动新 Activity.
的意图我试图用以下内容替换意图行:intending(isInternal()).respondWith(result);
以捕捉任何可能的意图,但没有成功。
知道如何让相同的功能在 Android 6 和 7 设备上运行吗?
尝试在您的 gradle 文件中进行这些更改
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test:runner:0.3') {
exclude group: 'com.android.support', module: 'support-annotations'
}
我已经在 issue tracker 上创建了一个错误票据,因为 intending 似乎没有按照文档中的描述工作,并且目标 activity 实际上是在具有较新版本 [= 的设备上启动的13=]。