android / android/android-test

Better error messages when no matching view was found in an Espresso test

Open
#219 2 comments 0 reactions 1 assignee Claimed by @adazh View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

### Description
Currently, when no matching view is found, Espresso throws an error message with a description of the view matcher itself (via decribeTo), with no mismatching message that could potentially help users understand why mismatching happens.
It will become painful when debugging a nested matcher like:
onView(firstOf(allOf(
withId(R.id.overflow_button),hasSibling(hasDescendant(withText("some title"))))))
.perform(CustomAction.click());

### Steps to Reproduce
An Espresso test that no View matches the given matcher.

### Expected Results
A more concise error message for debugging purposes, e.g. highlights potential matching views, suggesting correct matchers.

### Actual Results
Espresso prints out the matcher + entire view hierarchy.

### AndroidX Test and Android OS Versions

### Link to a public git repo demonstrating the problem:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.