-
Notifications
You must be signed in to change notification settings - Fork 550
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
Conversation
@anandwana001 PTAL. |
There was a problem hiding this 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.
@Sparsh1212 any update on this? |
Will resolve the conflicts and update it by today itself. |
@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. |
Trying to re-run the actions. |
There was a problem hiding this 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @Sparsh1212
Apologies--will need to look at this tomorrow. |
There was a problem hiding this 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.
testing/src/main/java/org/oppia/android/testing/RecyclerViewMatcher.kt
Outdated
Show resolved
Hide resolved
* within the item inside RecyclerView from a specified position. | ||
*/ | ||
fun verifyItemDisplayedOnRecyclerView( | ||
recyclerView: Int, |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
oppia-android/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt
Line 515 in 1e4c24c
@IdRes viewResId: Int |
Could targetView
also be annotated with IdRes
?
testing/src/main/java/org/oppia/android/testing/RecyclerViewMatcher.kt
Outdated
Show resolved
Hide resolved
@@ -1,12 +1,15 @@ | |||
package org.oppia.android.app.recyclerview | |||
package org.oppia.android.testing |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Apologies for the delay, I have my semester exams going on currently. |
Apologies--will need to look at this tomorrow. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
* Verifies that the item is displayed for a specific view | ||
* within the item inside RecyclerView from a specified position. |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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:
oppia-android/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt
Line 515 in 1e4c24c
@IdRes viewResId: Int |
Could targetView
also be annotated with IdRes
?
@@ -65,6 +68,24 @@ class RecyclerViewMatcher { | |||
} | |||
} | |||
|
|||
/** | |||
* This function verifies item displayed for a specific view |
There was a problem hiding this comment.
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.
Explanation
Fixes #2536: Shift RecyclerViewMatcher to Central testing utility
Checklist