Skip to main content

Posts

Showing posts with the label matchers

Espresso for Android 1.1 released!

Google Espresso Team just announced about the second 1.1 release of their small in size but huge in potential baby. The new features are: so expected swiping ViewActions - swipeRight() and swipeLeft() maybe even more desired multi-window support new type text ViewAction - typeTextIntoFocusedView(String stringToBeTyped) bugfixes and improvements The release notes available at android-test-kit page - release notes Espresso 1.1 . I'd also like to mention useful features that are not present at release notes page: added possibility to create custom Root matchers updated scrollTo() ViewAction for horizontal scroll view support added NoActivityResumedException which indicates that there are no activities in stage RESUMED added DrawerActions and DrawerMatchers and last but not least - new stylish logo Stay tuned!

Discovering Espresso for Android: matching and asserting view with text.

After more than a month of using great test tool from Google - Espresso for Android, I'd like to share with you some of my experience. I assume that you've already added espresso jar into your project, spent some time playing with Espresso samples and have basic understanding how this tool works. In this post I'll show how to match particular view with text or assert that it contains (or not) specified Strings. Before we start, you have to take a look at Hamcrest matchers - Hamcrest tutorial and API Reference Documentation , which are used together with Espresso's ViewAssertions and ViewMatchers and included into Espresso standalone library. Pay more attention to Matcher<java.lang.String> matchers. So, here we go. For simplicity following String "XXYYZZ" will be used as a expected text pattern. Espresso ViewMatchers class implements two String matcher methods withText() and withContentDescription() which will match a view which text is equal...