Hi I have the following code:
@RunWith(Test9Runner.class)
public class MainActivityTest
{
private MainActivity activity;
private Button pressMeButto
James Neville's answer works on 4.3. However, I used the AndroidX API, Espresso and Kotlin:
// scenario initialization is done in @Before setUp method, I did it here for brevity
val scenario = ActivityScenario.launch(MainActivity::class.java)
@Test fun test() {
onView(withId(R.id.button_id)).perform(click())
scenario.onActivity { activity ->
val intent = shadowOf(activity).nextStartedActivity
val shadowIntent = shadowOf(intent)
assertEquals(SearchResultsActivity::class.java, shadowIntent.intentClass)
}
}