assertj-automation
assertj-automation copied to clipboard
Invalid refactor to assertThatThrownBy when returning exception
What happened?
assertj-automation would try to convert org.junit.jupiter.api.Assertions.assertThrows
to an assertThatThrownBy
assertion when the return value of assertThrows
is used:
MyException e = assertThatThrownBy(() -> throwingMethod()).isInstanceOf(MyException.class);
However assertThatThrownBy
does not return the exception.
What did you want to happen?
Maybe use catchThrowableOfType
instead when the returned exception is used in follow-up code. Arguably, it could also be a hint to refactor the test code to do follow up assertions on the exception with chained methods on the assertThatThrownBy
clause.