基本上,我正在尝试测试在登录不正确后,邮箱字段中是否显示错误。
这个视图是:
<android.support.design.widget.TextInputLayout
android:id="@+id/ti_email"
android:paddingEnd="10dp"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingStart="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/et_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/authentication_email_placeholder"
android:inputType="textEmailAddress"
android:maxLines="1"
android:textSize="16sp"
tools:text="@string/placeholder_email"/>
</android.support.design.widget.TextInputLayout>
我尝试像这样做:
onView(withId(R.id.et_email))
.check(matches(hasErrorText(
ctx.getString(R.string.authentication_error_empty_email))));
hasErrorText
匹配器无法正常工作,但这个自定义匹配器完美地发挥了作用。 - sam9046