Is there a way to count elements with a certain id in Espresso?
I can do onView(withId(R.id.my_id))
but then I'm stuck.
I have a LinearLayout where I inject elements (not a ListView), and I want to test how many or those are to check whether they match expected behavior.
This can be achieved with a custom matcher. You can define one in Kotlin in the next way:
Here is the matcher that I came up with:
and the usage is: