dimanche 14 août 2016

AssertJ assert on the cause message

Is there a way when using AssertJ agains a method throwing an excetion to check that the message in the cause is equal to some string.

I'm currently doing something like:

assertThatThrownBy(() -> SUT.method())
            .isExactlyInstanceOf(IllegalStateException.class)
            .hasRootCauseExactlyInstanceOf(Exception.class);

and would like to add an assertion to check the message in the root cause.

Aucun commentaire:

Enregistrer un commentaire