How best to verify rows in a ListView/UITableView?

With UITest, I am testing some filtering functionality which filters results displayed in a ListView/UITableView. My test filters a known dataset with a hardcoded value. Therefore, I know how many results should be returned. I want to verify in my UITest that my ListView/UITableView has the correct number of rows AND that each row has the correct value based on the filter. I was able to figure this out as long as the results fit on one page. However, as soon as the number of rows exceed the page scroll limit, UITest only returns what is visible. I would need to scroll down, check the new rows displayed, and repeat until I reach the bottom. This is where I am stuck.

How can I count and check the value inside every row of a ListView/UITableView when scrolling is needed to see them all?

I can use ScrollDown() which seems to scroll exactly one page at a time, but how do I know when I reach the bottom? It would be nice if the scrolling methods returned a bool so we know if any scrolling actually happened.

Best Answers

Answers

  • As I post this question, I can feel some people wondering, "Why are you testing data results as part of a UI test? Shouldn't the data results be tested by web service unit tests or by a non-UI unit test which accesses the ViewModels and doesn't involve any devices or simulators?"

    Those are good questions and I would be very interested to hear people's thoughts. Should UITests be the only tests needed for mobile apps, or should we also have unit tests too? If we have unit tests too, then what do the UITests do to verify the test was successfull? Just not crash is good enough?

Sign In or Register to comment.