I've just started learning to use Robotium for testing my app. I have written a test case that resets a list of stats, and then checks if the values are equal to 0. The code is below:
public void testClearStats() {
solo.clickOnButton("Clear Stats");
solo.clickOnButton("Yes");
TextView views = (TextView) solo.getView(R.id.textViewsNum);
TextView prompts = (TextView) solo.getView(R.id.textPromptsNum);
TextView completions = (TextView) solo.getView(R.id.textCompleteNum);
assertEquals("0", views.getText().toString());
assertEquals("0", prompts.getText().toString());
assertEquals("0", completions.getText().toString());
}
The test was failing when it shouldn't because it was checking the values of the TextViews before their results were reset. To get around this, I added this line:
solo.waitForActivity(solo.getCurrentActivity().toString());
With this statement the test passes but it seems to take an unnecessary long time to complete. I was wondering if there was a better/correct way of way doing this, or is this the best way of doing it?
Thanks