how can I test listview by robotium? I just want to check if oncreate event the items goes into it.
my Activity has a method:
private void initListView() {
Adapter adapter =
new Adapter(this, myRepository.findAll());
listView.setAdapter(adapter);
}
MyRepository returns List. In the ActivityInstrumentationTestCase2 I want to put some items into respository and then test if listView contains elements.
public void testListView_IsNotEmpty() {
Item i = new Item();
i.setSomething("item1");
getActivity().getMyRepository().insert(i);
assertTrue(solo.searchText("item1"));
}
Is it via robotium possible do to that?
best regards
This is clear case for mocking framework. I recomment jMockit as it is most advanced and suitable to use against stubbed out android libraries. As you do not like to test classes provided by android itself ( you implicitely trust that they do right thing ) , you only have to test that:
Test case would look like this:
}
(note that I adjusted interface for easier mockability )