aryaxt
aryaxt

Reputation: 77616

Android & Robotium - waitForActivity doesn't fail when it's supposed to?

solo.clickOnButton("Login");
solo.waitForActivity("activityThatDoesntExist", 20000);

application navigates to an activity named "HomePageActivity", but the test passes even though the activity name is incorrect? Why does it pass?

Upvotes: 0

Views: 1548

Answers (2)

mlchen850622
mlchen850622

Reputation: 668

To make sure the test cases won't pass in case the expected activity doesn't show up, I usually add assertTrue method. like:

solo.clickOnButton("Login");
assertTrue(solo.waitForActivity("activityThatDoesntExist", 20000)); 

So when the expected activity doesn't exist, you can catch AssertionFailedError to fail your case.

Upvotes: 1

Huupke
Huupke

Reputation: 1155

waitForActivity() returns 'false' when the Activity isn't found within the timeout period.

Upvotes: 1

Related Questions