我需要在android-kotlin中使用espresso为无线电组编写测试用例,下面是我用过的xml。
<RadioGroup
android:id="@+id/radio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:checkedButton="@+id/production"
tools:ignore="MissingConstraints">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/env_select"
android:textStyle="bold"
android:textSize="20sp"
/>
<RadioButton
android:id="@+id/production"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/env_production"
/>
<RadioButton
android:id="@+id/development"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/env_development"
/>
<RadioButton
android:id="@+id/testing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/env_testing"
/>
</RadioGroup>
我试过一些代码
onView(withId(R.id.production))
.check(matches(isChecked()));
onView(withId(R.id.development))
.check(matches(not(isChecked())));
onView(withId(R.id.testing))
.check(matches(not(isChecked())));
但它显示为android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id:production
请帮我写相同的测试用例