Hi!
I've been working on ViewSelector, a library to make unit testing Android UIs easier with CSS-style selectors (partly inspired by Android's own UiSelector). It works with Android tests as well as with Robolectric (yes, also with the brand new 2.0). I've been using it successfully in my own projects but I'd like to get some feedback about the API from others before I put out a final release.
An example to give you a general idea:
// These traditional assertions ...
ListView view = (ListView) activity.findViewById(R.id.groceries);
assertEquals(2, view.getChildCount());
assertEquals("milk", ((TextView) view.getChildAt(0)).getText());
assertEquals("cereal", ((TextView) view.getChildAt(1)).getText());
// ... can be expressed with ViewSelector as:
assertThat(selection("ListView#groceries TextView", activity))
.hasSize(2)
.hasAttributesEqualTo("text", "milk", "cereal");
Does the API seem intuitive to you? Any other assertions that would be useful to you? There's an alpha release on Maven Central if you want to try it out.
Nik