android tutorial - Custom matcher for testing TextView in Android Espresso | Developer android - android app development - android studio - android app developement
Example of Custom matcher for testing TextView error message
- Create a class name ErrorMatcher inside your test package with below code:
Matching logic is to find the TextView element, which error message text is equal to expected error text value, going through the subset of TextView fields present in the layout hierarchy. describeTo method is used for debug output.
- Then you can use your custom matcher in the test case as shown below: