Issue
My app has ChipGroup
s with individual Chip
s inside. (Documentation) and (Description)
What I want to do is to use Espresso libraries in Android to test the functionality of these components. I want to click on the Chip
s, especially their close buttons, to delete them and check that they were actually removed, etc. I have not been able to find information about iterating over ChipGroup
s like with using the foreach
. The methods like Espresso.onView()
or .perform()
are missing this functionality. The closest I have come is seeing information on RecyclerView
s and ListView
s.
I have looked at the documentation here and the cheatsheet among others. Any idea what I ought to do to test these components?
Solution
As an option:
fun chipContainsText(text: String) {
onView(allOf(withText(containsString(text)), isAssignableFrom(Chip::class.java))).check(matches(isDisplayed()))
}
And I use it:
chipContainsText(1000)
In general, using isAssignableFrom(CLASS_NAME::class.java)
is always very helpful in difficult situations.
Layout Screenshot:
Answered By - imbirovsky
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.