Skip to end of metadata
Go to start of metadata

FEST Assertions Module has moved to Github !

Check this page :https://github.com/alexruiz/fest-assert-2.x/wiki

The documentation below is for Fest 1.x which is no more maintained, we are focusing our effort to the 2.x version !

 

FEST-Assert can also "decorate" user-defined assertion classes with the prefix assertThat, resulting in improved readability of test code.

The only condition is that user-defined assertion classes must extend org.fest.assertions.GenericAssert and set in first generic parameter the custom assertion class and in second the class you want to make assertions on.

The following example demonstrates a custom assertion class CharacterAssert that verifies the name of a Character, code is available here :

Let's play with our Character custom assertions !

The previous example shows few interesting things :

  • it is easy to call your custom assertions in Fest standard way with assertThat()
  • you keep taking advantage of Fest standard assertions.

Old documentation without self type (to use before Fest 1.4).

FEST-Assert can also "decorate" user-defined assertion classes with the prefix assertThat, resulting in improved readability of test code. The only condition is that user-defined assertion classes must implement the marker interface org.fest.assertions.AssertExtension.

The following example demonstrates an assertion class that verifies the state of a ServerSocket:

We can decorate that assertion class with assertThat: