Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Espresso NoMatchingViewException on check

I am trying out the new Android testing library Espresso. When I try:

onView(withId(R.id.gettingStarted))

The test runs fine. But when I try:

onView(withId(R.id.gettingStarted)).check(matches(isDisplayed()));

I get a .NoMatchingViewException: No views in hierarchy found matching: with id: is <2131296645>

Has anyone seen anything like this before? My initial reflex is that this is just a bug because Espresso is only on version 1.0. I am using Android Studio and followed the set up directions exactly.

like image 250
Zargoon Avatar asked Oct 25 '13 04:10

Zargoon


1 Answers

This is expected behavior.

onView(withId(R.id.gettingStarted)) by itself doesn't do anything. When you invoke the perform method, Espresso runs the matcher provided inside the onView method against the current view hierarchy - if no matching view is found, the exception is thrown.

See the start guide for more details: https://developer.android.com/training/testing/espresso/index.html

like image 137
ValeraZakharov Avatar answered Oct 10 '22 21:10

ValeraZakharov