Rory Danes
Rory Danes

Reputation: 157

No type arguments expected for class Matcher

I am trying to create a custom matcher for an espresso test. My code so far is:

private fun withCrossedOutText(): Matcher<View> {
    return object :  BoundedMatcher<View, TextView>(TextView::class.java) {
        override fun matchesSafely(item: TextView?): Boolean {
            // Code
        }

        override fun describeTo(description: org.hamcrest.Description?) {
            // Code
        }
    }
}

This gives an error on the first line saying

No type arguments expected for class Matcher

I have tried removing <View> but this creates more issues.

Upvotes: 0

Views: 351

Answers (1)

Rory Danes
Rory Danes

Reputation: 157

The issue was that the wrong Matcher package was imported. I was originally using regex Matcher but when I used Hamcrest Matcher the issue went away.

Upvotes: 2

Related Questions