Affects PMD Version: 6.55.0
Rule:
JUnitTestsShouldIncludeAssert
Description:
With AssertJ you can create assert chains in fluent style. It can happen that you save a part in a variable for reuse.
The assertThat() is not detected and the rule is triggered.
Code Sample demonstrating the issue:
import static org.assertj.core.api.Assertions.assertThat;
final var dataArea = assertThat(jaxb).isNotNull()
.extracting(JAXBElement::getValue)
.isNotNull();
Expected outcome:
PMD should detect the assertThat. When you remove the variable, the assertThat is detected.
Running PMD through:
Gradle