android / android/android-test

Improve error message for androidx.test.espresso.contrib.ActivityResultMatchers#hasResultCode

Open
#2,064 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

If there's a mismatch with [ActivityResultMatchers#hasResultCode](https://github.com/android/android-test/blob/073cda34684a05c7142cc2e9680f22bcd27d141d/espresso/contrib/java/androidx/test/espresso/contrib/ActivityResultMatchers.java#L60), you currently get an error message like this one, not showing the actual value:
```
java.lang.AssertionError:
Expected: has result code -1
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
```
Please override `describeMismatchSafely` with something like
`mismatchDescription.appendText("result code was " + item.getResultCode());`

Contributor guide

Open the contributing guide

Research direction

Open espresso/contrib/java/androidx/test/espresso/contrib/ActivityResultMatchers.java and start at ActivityResultMatchers#hasResultCode. Confirm how the mismatch is currently described and make the failure report the actual result code instead of the ActivityResult object. Done means a mismatch shows the returned result code.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.