Added by Alex Ruiz, last edited by Alex Ruiz on Nov 02, 2009

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

Starting with version 1.2, FEST-Assert supports custom error messages, replacing the default ones.

For example, the following assertion:

assertThat("Luke").isEqualTo("Yoda");

will fail with the following default message:

expected:<'[Yoda]'> but was:<'[Luke]'>

By using the method overridingErrorMessage(String) we can provide our own error message. From the previous example:

assertThat("Luke").overridingErrorMessage("'Luke' is not 'Yoda'")
                  .isEqualTo("Yoda");

will fail with the message:

'Luke' is not 'Yoda'