diff --git a/pmd-java/src/main/resources/rulesets/java/junit.xml b/pmd-java/src/main/resources/rulesets/java/junit.xml index 4b32204938..11d85d1779 100644 --- a/pmd-java/src/main/resources/rulesets/java/junit.xml +++ b/pmd-java/src/main/resources/rulesets/java/junit.xml @@ -403,18 +403,25 @@ public class MyTestCase extends TestCase { -When asserting a value is the same as a boolean literal, use assertTrue/assertFalse, instead of assertEquals. +When asserting a value is the same as a literal or Boxed boolean, use assertTrue/assertFalse, instead of assertEquals. 3 @@ -430,6 +437,10 @@ public class MyTestCase extends TestCase { assertEquals("myVar is true", true, myVar); // Bad assertEquals("myVar is false", false, myVar); + // Bad + assertEquals("myVar is true", Boolean.TRUE, myVar); + // Bad + assertEquals("myVar is false", Boolean.FALSE, myVar); } } ]]> diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/junit/xml/UseAssertTrueInsteadOfAssertEquals.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/junit/xml/UseAssertTrueInsteadOfAssertEquals.xml index f162876a4f..fe15fbd905 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/junit/xml/UseAssertTrueInsteadOfAssertEquals.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/junit/xml/UseAssertTrueInsteadOfAssertEquals.xml @@ -51,4 +51,46 @@ public class TestWithAssertEquals { } ]]> + + + + + 8 + + + + + + + 0 + + \ No newline at end of file