assertj-android icon indicating copy to clipboard operation
assertj-android copied to clipboard

AbstractTextViewAssert.hasText() leads to java.util.UnknownFormatConversionException if text contains "%"

Open larsblumberg opened this issue 11 years ago • 3 comments

Assuming that a text view contains the '%' character, calling

assertThat(textView).hasText("any text")

will throw java.util.UnknownFormatConversionException if the assertion fails (expected text is not actual text).

This is due to AssertionError.failureIfErrorMessageIsOverriden() calling MessageFormatter.instance().format().

The solution would be to escape '%' characters in the description to be formatted.

larsblumberg avatar Dec 16 '13 16:12 larsblumberg

Nice find.

JakeWharton avatar Dec 19 '13 21:12 JakeWharton

This seems like a bug in FEST, not this library specifically. It's attempting to do that format twice without proper escaping. I'll have to test with normal assertions to see if this happens.

JakeWharton avatar Jan 08 '14 09:01 JakeWharton

Thank you Jake

larsblumberg avatar Jan 11 '14 19:01 larsblumberg