I am starting unit testing with Robolectric. I have a button that when clicked will display a confirmation dialog to the user. When the user clicks on BUTTON_POSITIVE , a new action is launched, a click on BUTTON_NEGATIVE, nothing happens, the user remains in the current activity.
When using BUTTON_POSITIVE, I was able to test the following method:
dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick(); assertThat(currentActivity, new StartedMatcher(NextActivity.class));
In case of using BUTTON_NEGATIVE I am not sure what to say:
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick(); //What should I assert next to check I am still in currentActivity?
source share