square / assertj-android

A set of AssertJ helpers geared toward testing Android.
https://square.github.io/assertj-android/
Apache License 2.0
1.58k stars 156 forks source link

Add cursor column assertion #17

Closed arturdryomov closed 11 years ago

arturdryomov commented 11 years ago

I’m still not sure about this assertion goodness because of it’s side-effect (moving a cursor) :-?

JakeWharton commented 11 years ago

We definitely cannot be mutating the input (the Cursor) inside an assertion. However, I think you can accomplish the same thing using getColumnNames():

assertThat(actual.getColumnNames()) //
  .overridingErrorMessage("Expected to have column <%s> but did not.", column) //
  .contains(column);
arturdryomov commented 11 years ago

Yep, it works and it’s more elegant solution. Thank you, Jake.

JakeWharton commented 11 years ago

Awesome. Thanks!