If calling a static method in another class to create the consumer with the assertions the rule seems to fail to find them.
- versions used 9.3.0
class ExampleTest {
@Test
void test6103() throws Exception {
assertThatThrownBy(() -> {
throw new IllegalArgumentException("Message");
}).isInstanceOfSatisfying(IllegalArgumentException.class, hasMessage("Message")); //No violation
}
@Test
void test6103Outside() throws Exception {
assertThatThrownBy(() -> {
throw new IllegalArgumentException("Message");
}).isInstanceOfSatisfying(IllegalArgumentException.class, IllegalArgumentExceptionAssertion.hasMessage("Message")); //FP?
}
public static Consumer<IllegalArgumentException> hasMessage(String message) {
return e -> {
AssertionsForClassTypes.assertThat(e.getMessage()).isEqualTo(message);
};
}
}
Where IllegalArgumentExceptionAssertion is a class containing the exact same static method āhasMessageā.