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:

  1. Object
  2. String
  3. Collection
  4. Map
  5. Primitives (boolean, int, char, etc.)
  6. Arrays of Object
  7. Arrays of primitives
  8. BufferedImage
  9. Throwable
  10. File
  11. BigDecimal

It can be downloaded here. For Maven 2 users, the project's repository can be found at http://fest.googlecode.com/svn/trunk/fest/m2/repository/ (groupId: fest, artifactId: fest-assert).

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);