Skip to content

Instantly share code, notes, and snippets.

@heitorcolangelo
Last active August 20, 2016 13:53
Show Gist options
  • Save heitorcolangelo/fa31964c8fe8e395f17cbf2211828eb2 to your computer and use it in GitHub Desktop.
Save heitorcolangelo/fa31964c8fe8e395f17cbf2211828eb2 to your computer and use it in GitHub Desktop.
MainActivityTest.java - click on item scenario
@Test
public void whenClickOnItemList_shouldStartUserDetailsActivity_withExtra() {
server.enqueue(new MockResponse().setResponseCode(200).setBody(Mocks.SUCCESS));
mActivityRule.launchActivity(new Intent());
Intents.init();
Matcher<Intent> matcher = allOf(
hasComponent(UserDetailsActivity.class.getName()),
hasExtraWithKey(UserDetailsActivity.CLICKED_USER)
);
Instrumentation.ActivityResult
result = new Instrumentation.ActivityResult(Activity.RESULT_OK, null);
intending(matcher).respondWith(result);
onView(withId(R.id.recycler_view)).perform(actionOnItemAtPosition(0, click()));
intended(matcher);
Intents.release();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment