I have an Activity.java which includes some tabs. Each tab represents different Fragments. One tab namely Menu has a listview where the items are being fetched from API call.
Now, how can I write test cases for the items on listview?
I tried the code below :
onData(withId(R.id.navigation_menu)).check(matches(withText(R.string.log_out))) .perform(click());
Here, navigation_menu is the list name and log_out is the name of item string. But then I get the following error:
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching
The hierarchy is:
HomeActivity.java --> TabAdapter.java --> MenuFragment.java --> MenuListAdapter.java
So, what should be the test case for an item of a listview that resides in a fragment of an activity ? Please HELP!!