Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kmmraj/9341b27179e022b179cc93f206b7c792 to your computer and use it in GitHub Desktop.
Save kmmraj/9341b27179e022b179cc93f206b7c792 to your computer and use it in GitHub Desktop.
@Test
public void onCreate_shouldCall_fetchHomeMetaData(){
//Given
HomeActivityOutputSpy homeActivityOutputSpy = new HomeActivityOutputSpy();
HomeActivity homeActivity = Robolectric.setupActivity(HomeActivity.class);
// It must have called the onCreate earlier,
// we are injecting the mock and calling the fetchMetaData to test our condition
homeActivity.output = homeActivityOutputSpy;
//When
homeActivity.fetchMetaData();
//Then
Assert.assertTrue(homeActivityOutputSpy.fetchHomeMetaDataIsCalled);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment