skydoves / AndroidVeil

:performing_arts: An easy and flexible way to implement loading skeletons and shimmering effects on layouts for Android.
Apache License 2.0
1.52k stars 106 forks source link

Test coverage #34

Open Gelassen opened 1 year ago

Gelassen commented 1 year ago

Is your feature request related to a problem?

I had an issue to cover UI screen with shimmer by espresso integration test

Describe the solution you'd like:

            onView(allOf(withClassName(endsWith("RecyclerView")), isDisplayed()))
                .check(matches(CustomMatchers().recyclerViewSizeMatch(count)))
                                                                or
            onView(CustomMatchers().isThisRequiredListInShimmer(tagToMatch))
    fun isThisRequiredListInShimmer(tagToMatch: String): BoundedMatcher<View, RecyclerView> {
        return object : BoundedMatcher<View, RecyclerView>(RecyclerView::class.java) {

            override fun describeTo(description: Description) {
                description.appendText("RecyclerView in shimmer component should have defined tag $tagToMatch")
            }

            override fun matchesSafely(item: RecyclerView): Boolean {
                return item.tag != null && item.tag.equals(tagToMatch)
            }
        }
    }

Describe alternatives you've considered:

This a solution I implemented for my use case, but it would be good to have more elegant way to do this.