【发布时间】:2016-08-28 16:13:06
【问题描述】:
有时我会在我的应用程序中遇到罕见的错误。但我无法复制它,因为它非常罕见。所以,我决定写一个简单的浓缩咖啡测试:
@RunWith(AndroidJUnit4::class)
@LargeTest
class MainActivityTest {
val password = "1234"
@Rule @JvmField
var mActivityRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java)
@Test
fun checkNotesListNotEmpty() {
onView(withId(R.id.password_edit_text)).perform(typeText(password))
onView(withId(R.id.notes_recycler_view)).check { view, noMatchingViewException ->
if (noMatchingViewException != null) throw noMatchingViewException
assertThat((view as RecyclerView).adapter.itemCount, Matchers.`is`(1))
}
}
}
如何循环这个测试并在匹配失败时停止它?
【问题讨论】:
-
试试
fun checkNotesListNotEmpty() throws InterruptedException -
@piotrek1543 主要问题是我找不到多次运行 Espresso 测试的方法(循环中)。我该怎么做?
标签: android kotlin android-espresso