Я учусь uitest
, моя цель - тестирование RecyclerView
прокрутки. Когда я выполняю примеры кодов, возникает эта ошибка:
E/TestRunner: androidx.test.espresso.PerformException: Error performing 'scroll RecyclerView to position: 17' on view 'with id: com.jakchang.hwahae:id/recyclerView'.
at androidx.test.espresso.PerformException$Builder.build(PerformException.java:84)
blabla ~~
Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints:
Я искал это, но не могу найти ничего, чтобы решить эту проблему. Вот мой код Помогите мне пожалуйста:
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Rule
@JvmField
val mainActivity = ActivityTestRule(MainActivity::class.java)
@Test
fun useAppContext() {
//mainActivity.launchActivity(Intent())
Espresso.onView(ViewMatchers.withId(R.id.recyclerView))
.inRoot(RootMatchers.withDecorView(Matchers.`is`(mainActivity.activity.window.decorView)))
.perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(17))
Thread.sleep(10000)
}
}