When I run my test case, I got the following exception.
android.support.test.espresso.NoMatchingViewException: no views in hierarchy match found: with id: android: id / home
This is my TestCase code.
public void nav_to_alarm_test(){
onView(withId(R.id.navigation_notifications)).perform(click());
onView(withId(R.id.rl_reminder)).perform(click());
onView(withId(R.id.item_test)).perform(click());
onView(withId(android.R.id.home)).perform(click());
onView(withId(android.R.id.home)).perform(click());
}
This is android.R.id.home, belongs to a button provided by ActionBar
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.item_test:
startActivityForResult(CreateOrUpdateReminderActivity.class,CMD_ADD_REMINDER);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Why can't I find the views in the hierarchy for the id of the android.R.id.home resource? I have Google my problem, but the answers are not what I want.
Thanks for any help.
Cyrus source
share