我有一個Espresso用戶界面測試,使用intending存根啓動一個新的活動,當一個按鈕被點擊。 下面的代碼在安卓版本5.1及更低版本的設備上工作得很好,但是在安卓版本高於intending
的任何設備上似乎沒有像文檔中描述的那樣工作。Android Espresso不打算在Android版本上工作> 5
@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());
}
基本上我想檢查一個意圖是當一個特定的按鈕被點擊時觸發。但我實際上並不想要啓動新的活動。
我試圖用intending(isInternal()).respondWith(result);
來代替意圖行來捕捉任何可能的意圖也沒有成功。
任何想法如何獲得相同的功能在Android設備上工作?
爲什麼downvote? – Kai