deprecating fail() method

2 views
Skip to first unread message

Joel Costigliola

unread,
Jul 24, 2011, 11:45:54 AM7/24/11
to easytesting-dev
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

Ansgar Konermann

unread,
Jul 24, 2011, 12:37:18 PM7/24/11
to easytes...@googlegroups.com
Am 24.07.2011 17:45, schrieb Joel Costigliola:
> 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.
Very good idea IMHO, please do so.

Best

Ansgar

Reply all
Reply to author
Forward
0 new messages