fest-assert-2.x icon indicating copy to clipboard operation
fest-assert-2.x copied to clipboard

Add cause assertions to ThrowableAssert

Open ash2k opened this issue 13 years ago • 6 comments

Add two new assertions to ThrowableAssert:

hasCause(Throwable e);
hasRootCause(Throwable e);

Also, maybe (is this too specific?) add instanceOf checks for cause:

hasCauseOfClass(Class<? extends Throwable> eClass);
hasRootCauseOfClass(Class<? extends Throwable> eClass);

ash2k avatar Sep 14 '12 08:09 ash2k

I'll be removing ThrowableAssert from the code base. It provide little benefit since anything that you need to check in a Throwable can be done with other assertions.

alexruiz avatar Oct 05 '12 00:10 alexruiz

Pressed "Close" by accident. I'm leaving the issue open in case we'd like to discuss it further.

alexruiz avatar Oct 05 '12 00:10 alexruiz

From wiki:

FEST Assertions 2.0 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.
assertThat(throwable).hasRootCause(e);
assertThat(Throwables.getRootCause(throwable)).isEqualTo(e);

Dont you agree that the first sample is MUCH more radable?

Throwables is from Guava.

ash2k avatar Oct 05 '12 03:10 ash2k

It is more readable, no doubt. But we cannot provide an assertion for everything. We need to draw the line somewhere. We may reconsider after releasing 2.0.

alexruiz avatar Oct 05 '12 04:10 alexruiz

I agree with Mikhail, the thing that made me choose Fest over Hamcrest was the richness of Fest Assertions, IMHO this is why Fest is successfull (along with the ease of use).

Question is : do we had some user complain about providing too much assertions ?

I'm gonna post the question on the fest-dev list of where we should draw the line of what we provide. Maybe the solution would a small core assertions and an extended assertions module ... but let's disuss that on the dev-list.

joel-costigliola avatar Oct 05 '12 10:10 joel-costigliola

Good idea, Joel! I think automatic notification of issues (creation, updates) to the dev mailing list can be pretty helpful. This way, others can participate.

alexruiz avatar Oct 05 '12 14:10 alexruiz