Added by Alex Ruiz, last edited by Alex Ruiz on Feb 08, 2010  (view change)

Labels:

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

Welcome to the FEST Fluent Assertions Module

FEST-Assert is a Java library that provides a fluent interface for writing assertions. Its main goal is to improve test code readability and make maintenance of tests easier.

FEST-Assert requires Java SE 5.0 or later and can be used with either JUnit or TestNG.

Currently, this module provides assertions for the following data types:

  • Object
  • String
  • Collection
  • Map
  • Primitives (boolean, int, char, etc.)
  • Arrays of Object
  • Arrays of primitives
  • BufferedImage
  • Throwable
  • File
  • BigDecimal

It can be downloaded here. For Maven 2 users, details about the project's repository can be found at here.

Examples


int removed = employees.removeFired();
assertThat(removed).isZero();

List<Employee> newEmployees = employees.hired(TODAY);
assertThat(newEmployees).hasSize(6)
                        .contains(frodo, sam);

String[] newHires = employees.newHiresNames();
assertThat(newHires).containsOnly("Gandalf", "Arwen", "Gimli");

assertThat(yoda).isInstanceOf(Jedi.class)
                .isEqualTo(foundJedi)
                .isNotEqualTo(foundSith);

Custom Error Messages
Specifying custom error messages.

Extending
Extending FEST-Assert with custom conditions and assertions.

JUnit-Specific Features
FEST-Assert supports JUnit-specific features.

Comparing to Hamcrest
Comparing FEST-Assert and Hamcrest.