Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

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

Open
larsblumberg opened this issue Dec 16, 2013 · 3 comments

Comments

@larsblumberg
Copy link

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.

@JakeWharton
Copy link
Member

Nice find.

@JakeWharton
Copy link
Member

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.

@larsblumberg
Copy link
Author

Thank you Jake

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants