I essentially have a custom IdlingResource
that takes a View
a constructor argument. I can\'t find anywhere that really talks about how to implemen
If you are using ActivityScenarioRule
from androidx.test.ext.junit.rules
(since ActivityTestRule
"will be deprecated and eventually removed from library in the future"), you can get your Activity
instance and call findViewById
method:
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
@RunWith(AndroidJUnit4::class) {
@get: Rule
var testRule = activityScenarioRule()
@Test
fun mainTestCase() {
testRule.scenario.onActivity { activity ->
val view = activity.findViewById(R.id.view)
}
}
}