仅在启用动画时通过Espresso测试

时间:2019-06-03 14:49:32

标签: android android-espresso

我具有Espresso的一项测试功能,但只有在启用动画时才能通过此功能。我试图调用Thread.sleep(),但它也不能。这是我的测试:

@Rule
@JvmField
val rule = IntentsTestRule<DashBoardActivity>(DashBoardActivity::class.java, false, false)

@Test
fun onAcceptNewTask_ShouldMoveTheTaskToOpen() {
    rule.launchActivity(DashBoardActivity.newIntent(InstrumentationRegistry.getTargetContext()))

    onView(withId(R.id.tabViewPager)).perform(ViewPagerActions.scrollToPage(1))

    // This will show Task Detail
    onView(withRecyclerView(R.id.rvNewTasks).atPosition(0, R.id.btnAcknowledge)).perform(click())

    // back to the Task List
    pressBack()

    Thread.sleep(1_000)

    onView(allOf(withId(R.id.tvNewTasksEmpty), isDisplayed())).check(matches(withText(InstrumentationRegistry.getTargetContext().getString(R.string.no_new_tasks))))
}

0 个答案:

没有答案