@Before
public void setUp() throws Exception {
activity = new MainActivity();
activity.onCreate(null);
settingsButton = (Button) activity.findViewById(R.id.btnSettings);
}
@Test
public void shouldLaunchSettingsWhenClicked() {
settingsButton.performClick();
ShadowActivity shadowActivity = shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ShadowIntent shadowIntent = shadowOf(startedIntent);
assertThat(shadowIntent.getComponent().getClassName(), equalTo(SettingsActivity.class.getName()));
}
however when I run it, the assertion fails because getComponent() returns "null"
The app works fine, and this is my first Roboelectric test so I'm wondering what I've possibly missed that's making it not work?