android / android/android-test

RecyclerVIewActions.actionOnItem incorrect PerformExceprionCause when matched 0 or more than 1 item

Open
#1,218 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

### Description
RecyclerVIewActions.actionOnItem incorrect PerformExceprionCause when matched 0 or more than 1 item

### Steps to Reproduce
RecyclerView have more than 1 item with matcher, for example:

`onView(withId(R.id.recycler_view).perform(RecyclerViewActions.actionOnItem(isDisplayed(), click()))`

If RecyclerView have 2 or more items, this code throws `PerformException`, but `PerformException.cause` is `RuntimeException `instead of `AmbiguousViewMatcherException`

Same situation when RecyclerView does not have any item with matcher, for example (all RecyclerView items is displayed):

`onView(withId(R.id.recycler_view).perform(RecyclerViewActions.actionOnItem(not(isDisplayed()), click()))`

this code throws `PerformException`, but `PerformException.cause` is `RuntimeException `instead of `NoMatchingViewException`

### AndroidX Test and Android OS Versions
androidx.test.espresso:espresso-core:3.4.0

Contributor guide

Open the contributing guide

Research direction

Start at RecyclerViewActions.actionOnItem and reproduce both cases from the issue: multiple matching items and no matching items. Trace how PerformException is created and add or update focused tests so the cause is AmbiguousViewMatcherException for multiple matches and NoMatchingViewException for no matches.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.