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

hasText() in AbstractTextViewAssert fails for Spannables #28

Closed christopherperry closed 11 years ago

christopherperry commented 11 years ago

I'm doing

textView.setText(Html.fromHtml("<b>Some bold text</b> with other text"));

in code, and the assertion

assertThat(textView).hasText("<b>Some bold text</b> with other text");

fails with the message:

Expected text <<b>Some bold text</b> with other text> but was <<b>Some bold text</b> with other text>

I expect the assertion to pass because the text is the same.

JakeWharton commented 11 years ago

Seems like a bug in CharSequence or Spannable then. Sad.

JakeWharton commented 11 years ago

Oh no wait, it's a failure of both you and our API. We'll add something like hasTextString in the next version which does pure string comparison.

christopherperry commented 11 years ago

I don't fail!!! Haha, I tried to also compare like this as well:

assertThat(textView).hasText(Html.fromHtml("<b>Some bold text</b> with other text"));

so at least it compares the same object, but that also fails.