Affects PMD Version: 6.42
Rule: SimplifiableTestAssertion
Description:
The rule seems to catch usage of assertTrue/assertFalse that contains inside any sort of equal operator, without checking if it's the actual Object equality, nor if there are actual Assert methods that can be used as a replacement.
Code Sample demonstrating the issue:
// no such thing as a Assert.assertNotEqualsIgnoreCase to replace this (would require full Hamcrest library dependency, not covered by CoreMatchers)
assertTrue(!"0".equalsIgnoreCase(doc.select("mapml-viewer").attr("zoom")));
// this equality method takes as extra parameters a comparison tolerance, the signature is
// public boolean equals(final Envelope envelope, final double eps, final boolean epsIsRelative) {
assertTrue(outputReader.getOriginalEnvelope().equals(ROI, DELTA, false));
// no such thing as Assert.assertArraysNotEquals (though easy to replace with Hamcrest CoreMatchers, if available in the classpath, may not be if using JUnit 5)
Assert.assertFalse(Arrays.equals(destImageRowBand0, srcImageRowBand0));
Expected outcome:
In general, SimplifiableTestAssertion should verify the "equals" call inside the assertion is actually an override of Object.equals, and when suggesting to replace AssertFalse, check that the equivalent inequality assertion is available.
Running PMD through: [Maven]
Affects PMD Version: 6.42
Rule: SimplifiableTestAssertion
Description:
The rule seems to catch usage of
assertTrue/assertFalsethat contains inside any sort ofequaloperator, without checking if it's the actual Object equality, nor if there are actual Assert methods that can be used as a replacement.Code Sample demonstrating the issue:
Expected outcome:
In general, SimplifiableTestAssertion should verify the "equals" call inside the assertion is actually an override of
Object.equals, and when suggesting to replace AssertFalse, check that the equivalent inequality assertion is available.Running PMD through: [Maven]