android - 类 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
}
}
}
这在第一行给出了一个错误说
类 Matcher 不需要类型参数
我试过删除<View>
,但这会产生更多问题。
解决方案
问题是导入了错误的 Matcher 包。我最初使用的是正则表达式匹配器,但是当我使用 Hamcrest Matcher 时,问题就消失了。
推荐阅读
- r - 如何在不使用长度()的情况下调用 data.frame 中的最后一个单元?
- javascript - 滚动到页面中的某个位置后如何动态渲染元素?
- javascript - 如何获取由 Javascript 使用 Java / Webdriver 生成的网页的整个源 html 代码?
- swift - 如果新用户注册成功,如何打开一个屏幕,当现有用户使用 SwiftUI 成功登录时如何打开另一个屏幕?
- c# - 锁定列表会产生死锁
- python - 多个序列的并行处理
- jenkins - 如何将 Cmd 行输出定向到 jenkins
- angular - 输出 Angular 9 SSR 中的 sourceMappingURL
- node.js - 为什么猫鼬验证器不验证字段类型?
- c# - 在 MVC 中,为什么我的控制器需要接收“new { id = restaurant.Id }”,而不是“restaurant.Id”?不都是简单的int吗?