FEST-Assert 1.0a1 released!

We are proud to announce that FEST-Assert 1.0a1 is out!

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

Example:

int removed = employees.removeFired();
assertThat(removed).isZero();
 
List 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);

Changelog:

  1. Exceptions thrown by methods satisfies and doesNotSatisfy include the name of Conditionclass if the Condition's description is not specified. For example, the following code listing will fail with the message "actual value:<'hello'> should satisfy condition:<UpperCase>":

    assertThat("hello").satisfies(new UpperCase());
    

    where UpperCase is defined as:

    class UpperCase extends Condition<String> {
      public boolean matches(String value) {
        if(isEmpty(value)) return false;
        return value.equals(value.toUpperCase());
      }
    }

  2. Added method doesNotSatisfy to all assertions. Fixes issue 46. Many thanks to Mark Derricutt.
  3. Patch: Added support for BigDecimal. Fixes issue 107. Many thanks to Ted Young and David DIDIER.
  4. Method hasSameContentAs(File) in FileAssert now includes all the differences found when comparing the contents of two files (previously it only showed the first difference.)
  5. Added method isEmptyOrNull to BooleanArrayAssert, ByteAssertArray, CharArrayAssert, CollectionAssert, DoubleArrayAssert, FloatArrayAssert, IntArrayAssert, LongArrayAssert, MapAssert, ShortArrayAssert and StringAssert.
  6. Added fest-mocks-0.1 and fest-test-0.1 as a 'test' scoped dependencies.
  7. Added method message to ThrowableAssert. This method returns a StringAssert.
  8. Added method hasMessage(String) to ThrowableAssert.
  9. Added method size to FileAssert. This method returns a LongAssert.
  10. Fixed bug in FileContentComparator where EOF (end of file) was determined at the wrong time.
  11. Replaced methods hasCauseAsAncestor and hasExactCauseAsAncestor in ThrowableAssert with the methods hasCauseOfType and hasCauseOfExactType in CauseHierarchyAssert. To get a CauseHierarchyAssert, users need to call the method causeHierarchy in ThrowableAssert. For example, the following code listing:

    assertThat(catchedException).causeHierarchy().hasCauseOfType(IOException.class);
    

    now replaces:

    assertThat(catchedException).hasCauseAsAncestor(IOException.class);
    

    Although the new version is longer, its purpose is easier to understand (that is, to verify if the catchedException has a cause of type IOException in its hierarchy of causes.)

  12. Replaced method hasCauseOfType in ThrowableAssert with method cause, which returns another ThrowableAssert for the cause of the actual Throwable. Users can call isInstanceOf in the returned ThrowableAssert.
  13. Method isInstanceOf in ObjectAssert and ThrowableAssert throws IllegalArgumentException if the given Class is null.
  14. Method isInstanceOfAny in ObjectAssert throws IllegalArgumentException if the given Class array is null or if any element in the given Class array is null.
  15. Fixed typos in Javadocs for class PrimitiveFail. Many thanks to Ted Young.
  16. Removed dependency on Apache Velocity.
  17. Removed code generators for assertions for primitive arrays and failure methods for primitives.
  18. Added missing declaration of exceptions in Javadocs.
  19. Eliminated inconsistencies and typos in exception messages.
  20. Added more tests, from 540 to 1523, with code coverage of 99.7%.

You can download the latest release here (file fest-assert-1.0a1.zip.) FEST-Assert requires Java SE 5.0 or later.

Here are some useful links:

Feedback is always appreciated

Comments [0]

Comments:

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed