我有一个singleInstance
活动,我是通过规则在测试中启动的:
@Rule
@JvmField
val activityRule = ActivityTestRule(MyActivity::class.java)
在测试中,我需要我的活动来处理几个新的意图,例如:
@Test
fun myTest() {
val context = InstrumentationRegistry.getTargetContext()
myTestParams.forEach { param ->
context.startActivity(Intent(context, MyActivity::class.java).putExtra("param", param))
InstrumentationRegistry.getInstrumentation().waitForIdleSync() // try to make espresso wait for intent being handled. DOESN'T WORK
takeScreenshot() // sometimes screenshot is taken before activity is rendered with new param
}
}
是否有任何方法可以使浓缩咖啡在执行MyActivity.onNewIntent
之前等待调用takeScreenshot
的方法?