Skip to content

Instantly share code, notes, and snippets.

@cdmunoz
Created October 13, 2018 23:11
Show Gist options
  • Save cdmunoz/b703168714cdeff4a45dbcbb68349925 to your computer and use it in GitHub Desktop.
Save cdmunoz/b703168714cdeff4a45dbcbb68349925 to your computer and use it in GitHub Desktop.
WhitListSize: Custom Espresso Matcher which checks if a ListView has an specific size
fun withListSize(size: Int): Matcher<View> {
return object : TypeSafeMatcher<View>() {
public override fun matchesSafely(view: View): Boolean {
return (view as ListView).count == size
}
override fun describeTo(description: Description) {
description.appendText("ListView should have $size items")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment