Skip to content

[java] A false negative about the rule SimplifiableTestAssertion #4062

@ghost

Description

Affects PMD Version:6.47.0

Rule:SimplifiableTestAssertion

Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/pmd-6.47.0/pmd_rules_java_bestpractices.html#simplifiabletestassertion

Description:
Hi, I found a false negative about the rule SimplifiableTestAssertion, please read the following code example. In line 6, PMD should have reported a warning because this line can be simplified into assertEquals(a, b);, but it doesn't. Hence, I think this is a false negative. Thanks.

Code Sample demonstrating the issue:

public class A {
    class B {
        Object a, b;
        @Test
        public void test() {
            assertTrue(a.equals(b));  // should report a warning in this line
        }
    }
}

Expected outcome:

PMD should report a violation at line 6, but doesn't. This is a false-negative.

Running PMD through: [Maven]

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-negativePMD doesn't flag a problematic piece of code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions