assertj-automation
assertj-automation copied to clipboard
Prefer AssertJ does not convert exceptions returned from Junit assertThrows
What happened?
If the returned Throwable of Junit's assertThrows
is used for further checks, the build breaks when the "Prefer AssertJ" conversion is applied. This is because AssertJ's assertThatThrownBy
does not return a Throwable.
Example from a PR:
- Throwable throwed = assertThrows(() -> foo());
- assertThat(throwed.getMessage()).contains("My error msg");
+ Throwable throwed = assertThatThrownBy(() -> foo()); // This breaks
+ assertThat(throwed.getMessage()).contains("My error msg");