I'm trying to create a test method using Robotium to check if the Android application finishes after clicking on a button (in the code there is a call to finish()
when the user taps on it).
public void test_onclickExit_finish() {
String buttonText = resources.getString(R.string.exit);
Button exitButton = solo.getButton(buttonText, true);
solo.clickOnView(exitButton);
// check here that the app has finished
// wait for the activity to finish?
assertTrue(solo.getCurrentActivity() == null);
}
But this test is failing. I don't know how can I indicate the test to wait till the activity has finished. Also I'm not sure if using getCurrentActivity()
would be a good way to check if the app has finished.
How can I check that the application/ activity has finished?
Thanks.