When testing android UI what's the proper way of waiting for UI to be ready?

Calling waitForIdleSync() is better than sleeping for a fixed time.


You have to do a Thread.sleep. I don't think there's a way around this. I don't see why that's "clunky"; you're doing a test, so you have to wait for the system to show the UI element you want to test.

It seems to me, though, that you're really trying to test AccountsList or list. There's little reason to test ListView or findViewById unless you're paranoid.

You should focus on testing AccountsList and your custom adapter. You shouldn't have to use the UI to do this.