Reputation: 355
Eclipse 2019-09, Java 11.0.5, PMD plugin 4.8.0
@Test
public final void testValueOf() {
final String message = "Colour Object correctly set?";
assertEquals(diamond, QCardColour.valueOf('d'), message);
assertEquals(heart, QCardColour.valueOf('h'), message);
assertEquals(spade, QCardColour.valueOf('s'), message);
assertEquals(club, QCardColour.valueOf('c'), message);
assertThrows(IllegalArgumentException.class, () -> {
QCardColour.valueOf('B');
}, message);
}
PMD eclipse plugin marks the assertEquals with JUnit assertions should include a message
which obviously is wrong. Gradle pmd plugin, working with the same ruleset.xml, shows no errors. How do i get rid of those messages without deactivating the rule?
Edit: The error shows up only in one project. In at least two other projects where assertEquals is in use, everything is fine.
Upvotes: 1
Views: 228
Reputation: 34137
This sounds like PMD issue 1009 which has been fixed some time ago. PMD 6.19.0 should contain this fix. The fix makes the rule less strict to handle both, JUnit 4 (where in assertEquals
the message is the first parameter) and JUnit 5 (message is the third parameter).
It's unclear why you're running into this issue with the pmd-eclipse-plugin 4.8.0 as it should contain PMD 6.19.0 with the fix for JUnit 5. You might report the issue to the pmd-eclipse-plugin team. There is more than one Eclipse PMD plug-in that you might use, at least until the issue is fixed.
Upvotes: 1