我不確定在Espresso測試中它是否正確實現「for循環」。我想在ExpandableListView中測試所有父母的第一個孩子。 潛在代碼:Android測試:在Espresso測試中,它是否正確實現「for Loop」?
for(i = 0; i < length; i++){
onData(anything())
.inAdapterView(withId(R.id.userProfileActivityList))
.atPosition(i)
.check(matches(isDisplayed()))
.perform(click())
.check(matches(hasDescendant(isDisplayed())));
}
非常感謝。
測試的一般經驗法則是每個方法一個斷言。如果你想創建一個數組並對另一組值進行驗證,那麼它就沒問題。你究竟想要對它進行測試呢? – sumandas
你好,謝謝你的回覆。其實我想測試每個統一的父母是可點擊和顯示的,並且每個父母也有顯示的統一的孩子。 –