用 "hasTextColor" 测试浓缩咖啡

Test with espresso with "hasTextColor"

如何使用文本颜色进行浓缩咖啡测试? 目前使用 hasTextColor():

onView(withId(R.id.editText)).check(matches(hasTextColor(Color.BLACK)));

但是出现错误:

android.content.res.Resources$NotFoundException: Resource ID #0xff000000 at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:195)

...

详情:

<EditText
 android:id="@+id/editText"
 android:textColor="#ff000000"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_marginTop="48dp"/>

您需要对照 hasTextColor(R.color.red)

等资源中定义的颜色进行检查

它也写在您提供的文档中 link: colorResId : int