Skip to content

Instantly share code, notes, and snippets.

@larkintuckerllc
Created November 29, 2017 01:12
Show Gist options
  • Save larkintuckerllc/58a996c78bf82f49842e27bfc702671a to your computer and use it in GitHub Desktop.
Save larkintuckerllc/58a996c78bf82f49842e27bfc702671a to your computer and use it in GitHub Desktop.
How-to Dagger 2 with Android: Part 2 - 6
...
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<MainActivity>(MainActivity.class) {
@Override
protected void beforeActivityLaunched() {
MyApplication application = (MyApplication) InstrumentationRegistry
.getInstrumentation()
.getTargetContext()
.getApplicationContext();
MyComponent myComponent = DaggerMyComponentMock
.builder()
.myModuleMock(new MyModuleMock())
.build();
application.setMyComponent(myComponent);
}
};
@Test
public void formattedDateShown() {
onView(withId(R.id.tvDate)).check(matches(withText("Wed Dec 31 19:00:00 EST 1969")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment