Why is my assertion failing when I am trying to assert the amount of textviews in a list ?
@Test
public void testDeleteNote() throws Exception {
int count= getNoOfTextViews();
// Checking if count is greater than 0.
if (count > 0) {
// Iterating count times
for (int i = 0; i < count; i++)
{
// Checking if count is even or odd.
if (i % 2 == 0) {
solo.clickInList(0);
deleteNote();
} else {
// Clicking Long on the 1st item in the Notes List.
solo.clickLongInList(0);
// Clicking on Delete String.
solo.clickOnText(solo.getString(R.string.menu_delete));
}
}
count = getNoOfTextViews();
// Asserting all the text views are deleted.
assertEquals(0, count);
}
public int getNoOfTextViews() {
// Getting the count of text views in the activity.
ArrayList<TextView> textView = solo.getCurrentViews(TextView.class,
solo.getCurrentViews(ListView.class).get(0));
return textView.size();
}
The failure I am seeing is:
junit.framework.AssertionFailedError: expected:<0> but was:<1>
UPDATE: I am seeing that this passes when i debugg, it fails only when i run the test case.