class 匹配器不需要类型参数
No type arguments expected for class Matcher
我正在尝试为浓缩咖啡测试创建自定义匹配器。到目前为止我的代码是:
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
}
}
}
第一行出现错误
No type arguments expected for class Matcher
我曾尝试删除 <View>
,但这会产生更多问题。
问题是导入了错误的 Matcher 包。我最初使用的是正则表达式匹配器,但当我使用 Hamcrest 匹配器时,问题就消失了。
我正在尝试为浓缩咖啡测试创建自定义匹配器。到目前为止我的代码是:
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
}
}
}
第一行出现错误
No type arguments expected for class Matcher
我曾尝试删除 <View>
,但这会产生更多问题。
问题是导入了错误的 Matcher 包。我最初使用的是正则表达式匹配器,但当我使用 Hamcrest 匹配器时,问题就消失了。