Skip to content
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

Fix #2536: Shift RecyclerViewMatcher to Central testing utility #3030

Closed
wants to merge 9 commits into from
Closed

Fix #2536: Shift RecyclerViewMatcher to Central testing utility #3030

wants to merge 9 commits into from

Conversation

Sparsh1212
Copy link
Contributor

@Sparsh1212 Sparsh1212 commented Mar 30, 2021

Explanation

Fixes #2536: Shift RecyclerViewMatcher to Central testing utility

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The PR follows the style guide.
  • The PR does not contain any unnecessary auto-generated code from Android Studio.
  • The PR is made from a branch that's not called "develop".
  • The PR is made from a branch that is up-to-date with "develop".
  • The PR's branch is based on "develop" and not on any other branch.
  • The PR is assigned to an appropriate reviewer in both the Assignees and the Reviewers sections.

@Sparsh1212
Copy link
Contributor Author

@anandwana001 PTAL.

Copy link
Contributor

@anandwana001 anandwana001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we have few failure, I think we face the similar failure in the last closed PR. Could you take a look and fix it.

@anandwana001
Copy link
Contributor

@Sparsh1212 any update on this?

@Sparsh1212
Copy link
Contributor Author

Will resolve the conflicts and update it by today itself.

@Sparsh1212
Copy link
Contributor Author

@anandwana001 I have resolved the merge conflicts, and also updated the PR. But some checks still fail, can you please take a look why they are still failing.

@Sparsh1212 Sparsh1212 assigned anandwana001 and unassigned Sparsh1212 Apr 6, 2021
@anandwana001
Copy link
Contributor

Trying to re-run the actions.

Copy link
Contributor

@anandwana001 anandwana001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sparsh1212 So far looks good to me.
Left a nit update.

Also, mark the checklist which are completed

@Sparsh1212 Sparsh1212 assigned anandwana001 and unassigned Sparsh1212 Apr 7, 2021
Copy link
Contributor

@anandwana001 anandwana001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@anandwana001 anandwana001 assigned rt4914 and unassigned anandwana001 Apr 7, 2021
Copy link
Contributor

@rt4914 rt4914 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @Sparsh1212

@rt4914 rt4914 assigned BenHenning and unassigned rt4914 Apr 8, 2021
@BenHenning
Copy link
Member

Apologies--will need to look at this tomorrow.

Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Sparsh1212! Leaving some initial thoughts.

* within the item inside RecyclerView from a specified position.
*/
fun verifyItemDisplayedOnRecyclerView(
recyclerView: Int,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This & targetView should be annotated with ViewRes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't import this annotation. Can you please guide me here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I should have instead said IdRes. See reference:

Could targetView also be annotated with IdRes?

@@ -1,12 +1,15 @@
package org.oppia.android.app.recyclerview
package org.oppia.android.testing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ought to have a subpackage for this.

@fsharpasharp or @anandwana001 do you have any thoughts on how we should organize where Espresso helpers go in the testing package?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in one of the PR we are doing org.oppia.android.testing.robolectric so we can go with org.oppia.android.testing.espresso

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good to me. WDYT @Sparsh1212?

@@ -65,6 +68,24 @@ class RecyclerViewMatcher {
}
}

/**
* This function verifies item displayed for a specific view
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While here, could you also add tests for these view matchers? It's important to make sure our test utilities work correctly, so having a RecyclerViewMatcherTest would be really helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please give me a reference or anything like that for writing a test for the ViewMatchers. That would be really helpful for me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have any tests for matchers yet (@anandwana001 can you confirm?), so this might be a new thing.

To start, I suggest copying an existing test suite & clearing out all of the modules & tests to start from a fresh state. In order to test these methods you'll need to create a test activity and test layout file (search for 'TestActivity' for examples of this in app module tests) where the layout file sets up test views to specifically test different conditions for these matchers.

If you're unsure how to write the tests, I suggest starting with setting up the test environment (e.g. the layout & activity) and then push those changes. We can provide further guidance on writing specific tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we don't have any tests for matchers yet.

@anandwana001 anandwana001 removed their assignment Apr 12, 2021
@Sparsh1212
Copy link
Contributor Author

Apologies for the delay, I have my semester exams going on currently.
@anandwana001 Will it be okay if I finish this by the end of this week.

@BenHenning
Copy link
Member

BenHenning commented Apr 23, 2021

Apologies--will need to look at this tomorrow.

Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Sparsh1212! Left a few comments. PTAL when you get a chance.

@@ -1,12 +1,15 @@
package org.oppia.android.app.recyclerview
package org.oppia.android.testing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good to me. WDYT @Sparsh1212?

Comment on lines +72 to +73
* Verifies that the item is displayed for a specific view
* within the item inside RecyclerView from a specified position.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here & elsewhere: please make sure KDocs fit the entire line (100 character cut-off) before being wrapped.

* Verifies that the item is displayed for a specific view
* within the item inside RecyclerView from a specified position.
*/
fun verifyItemDisplayedOnRecyclerView(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps instead: verifyItemDisplayedInRecyclerView? 'On' doesn't seem like the correct preposition to use here.

* within the item inside RecyclerView from a specified position.
*/
fun verifyItemDisplayedOnRecyclerView(
recyclerView: Int,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I should have instead said IdRes. See reference:

Could targetView also be annotated with IdRes?

@@ -65,6 +68,24 @@ class RecyclerViewMatcher {
}
}

/**
* This function verifies item displayed for a specific view
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have any tests for matchers yet (@anandwana001 can you confirm?), so this might be a new thing.

To start, I suggest copying an existing test suite & clearing out all of the modules & tests to start from a fresh state. In order to test these methods you'll need to create a test activity and test layout file (search for 'TestActivity' for examples of this in app module tests) where the layout file sets up test views to specifically test different conditions for these matchers.

If you're unsure how to write the tests, I suggest starting with setting up the test environment (e.g. the layout & activity) and then push those changes. We can provide further guidance on writing specific tests.

@anandwana001 anandwana001 removed their assignment Apr 28, 2021
@anandwana001 anandwana001 added the PR don't merge - NEEDS UPDATE Corresponds to PRs that need to be updated with the latest develop changes before they can be merged label May 7, 2021
@Sparsh1212 Sparsh1212 closed this Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR don't merge - NEEDS UPDATE Corresponds to PRs that need to be updated with the latest develop changes before they can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce a central utility for matching item in RecyclerView [Testing]
5 participants