Utility method to ease writing custom assertions classes using
String#format(String,Object...) specifiers
in error message.
Moreover, this method honors any description set with
#as(String,Object...) or overridden error message
defined by the user with
#overridingErrorMessage(String,Object...).
Example :
public TolkienCharacterAssert hasName(String name) {
// check that actual TolkienCharacter we want to make assertions on is not null.
isNotNull();
// check condition
if (!actual.getName().equals(name)) {
failWithMessage("Expected character's name to be <%s> but was <%s>", name, actual.getName());
}
// return the current assertion for method chaining
return this;
}