2017-05-04 29 views
-1

我有一個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設備上工作?

+0

爲什麼downvote? – Kai

回答

0

,因爲我打算創建於issue tracker一個bug票似乎並不在這個文檔描述和目標的活動是在設備實際推出合作與更新版本的機器人。

0

試着在你做了這些改變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' 
} 
+0

感謝您的回覆。我已經有我的build.gradle文件中的那些。 – Kai

相關問題