我試圖在Robotium中運行一些自動化測試,方法是迭代列表並單擊每個列表元素以啓動另一個活動。我有下面的代碼在我的測試方法:遍歷列表並單擊Robotium中的列表項目
代碼:
solo.assertCurrentActivity("Wrong activity", MainActivity.class);
//Clicks on the action bar tab
solo.clickOnText("Charts");
ArrayList<ListView> list = solo.getCurrentListViews();
for(int i = 0; i < list.size(); i++) {
//Clicks on the list item assert that the new activity is started
solo.clickInList(chartPosition);
solo.assertCurrentActivity("Json Class", JsonActivity.class);
//Go back to the list
solo.goBack();
}
上面的代碼不點擊任何列表項和JUnit測試結果顯示,所有測試都通過了,這是非常令人困惑。
有沒有人如何成功遍歷Robotium中的列表?
我見過類似這個問題的另一個問題,但答案建議看看jMock而不是幫助。