Hi,
I think the fail()method taking no parameters should be deprecated,I
think it fosters a bad practice : not giving meaningful error message.
I often see in my current project the code (anti)pattern
try {
somethingThatShouldThrowFNFE();
fail();
} catch (FileNotFoundException e) {
// assertions on e
}
When the test fails we don't why.
The preferred way should be
try {
somethingThatShouldThrowFNFE();
fail("Expected FileNotFoundException to be thrown");
} catch (FileNotFoundException e) {
// assertions on e
}
or even better after fixing
http://jira.codehaus.org/browse/FEST-387
try {
somethingThatShouldThrowFNFE();
failBecauseExceptionWasNotThrown(FileNotFoundException.class);
} catch (FileNotFoundException e) {
// assertions on e
}
I even think to remove fail() in Fest Assert 2.0 as we can afford some
breaking changes, this one being easy to solve by our users.
Any comments ?
Joel