-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce a central utility for matching item in RecyclerView [Testing] #2536
Comments
@anandwana001 Can you elaborate more ? I want to work in this issue . this seems interesting but don't know how to proceed |
Thanks @ayan-biswas0412 for showing interest. If you see test files in the app Module, one file referenced in the description above, we use to test alot about if the item is visible on the particular index in RecyclerView. So instead of writing this multiple times, we need a new file, a central utility, something like EditTextInputAction, where we can put our main function of checking items in RecyclerView, and just use it wherever required. |
sure I will complete the onboarding first |
I would love to work on this. @anandwana001 Shall I assign this to myself ? |
@anandwana001 As per what I have understood, I am required to shift this helper function to a new file and make it generic to use the Helper Function in private fun verifyItemDisplayedOnAdministratorControlListItem(
itemPosition: Int,
targetView: Int
) {
onView(
atPositionOnView(
recyclerViewId = R.id.administrator_controls_list,
position = itemPosition,
targetViewId = targetView
)
).check(matches(isDisplayed()))
} Generalize this to: in a new central utility file private fun verifyItemDisplayedOnRecyclerView(
recyclerView: Int,
itemPosition: Int,
targetView: Int
) {
onView(
atPositionOnView(
recyclerViewId = recyclerView,
position = itemPosition,
targetViewId = targetView
)
).check(matches(isDisplayed()))
} |
@anandwana001 Please confirm this. |
Sounds good to me @Sparsh1212 |
@anandwana001 I am facing problem while importing
And I think its not a gradle sync issue, do we have to add any dependency in the |
Yes, as testing is a new module so you have to check if the required dependency is already there or not, if not we have to add it. |
Hi @adhiamboperes, Please check the below screenshots if they align with the specifications so I can go ahead and continue with other functions and then make a PR. |
…iew (#5391) <!-- READ ME FIRST: Please fill in the explanation section below and check off every point from the Essential Checklist! --> ## Explanation Fix #2536 I worked on the below functions renaming the title and adding an argument for the recyclerviewId to each function to make it reusable, I also added kdocs to help understand the functions. P.S:- I created the functions in the RecyclerviewMatcher class. ![Screenshot 2024-04-30 at 01 24 45](https://github.com/oppia/oppia-android/assets/54560535/6a0464e0-e72f-4516-83e1-3a53d2025a6b) ![Screenshot 2024-04-30 at 01 24 26](https://github.com/oppia/oppia-android/assets/54560535/34332586-e082-4991-9b6b-b8f8c647e7d0) ![Screenshot 2024-04-30 at 01 24 57](https://github.com/oppia/oppia-android/assets/54560535/7090b959-fb45-4787-9957-7e182d47a042) ## Essential Checklist <!-- Please tick the relevant boxes by putting an "x" in them. --> - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).
Is your feature request related to a problem? Please describe.
While writing test cases in the app module for testing, if the item matches the RecyclerView's item, we use
atPositionOnView
heavily.Describe the solution you'd like
Create a central utility which we can directly use in our test files.
As for this issue, after creating this central utility, use it in the
AdministratorControlsActivityTest
only.Additional context
In some of the file, we had created helper functions,
example -
verifyItemDisplayedOnAdministratorControlListItem
inAdministratorControlsActivityTest
The text was updated successfully, but these errors were encountered: