diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnitAssertionsShouldIncludeMessageRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnitTestAssertionsShouldIncludeMessageRule.java similarity index 90% rename from pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnitAssertionsShouldIncludeMessageRule.java rename to pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnitTestAssertionsShouldIncludeMessageRule.java index 915415a0a3..78be7c765e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/JUnitAssertionsShouldIncludeMessageRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnitTestAssertionsShouldIncludeMessageRule.java @@ -10,7 +10,7 @@ import net.sourceforge.pmd.lang.java.rule.internal.TestFrameworksUtil; import net.sourceforge.pmd.lang.java.types.InvocationMatcher; import net.sourceforge.pmd.lang.java.types.InvocationMatcher.CompoundInvocationMatcher; -public class JUnitAssertionsShouldIncludeMessageRule extends AbstractJavaRulechainRule { +public class UnitTestAssertionsShouldIncludeMessageRule extends AbstractJavaRulechainRule { private final CompoundInvocationMatcher checks = InvocationMatcher.parseAll( @@ -28,7 +28,7 @@ public class JUnitAssertionsShouldIncludeMessageRule extends AbstractJavaRulecha "_#assertEquals(double,double,double)" ); - public JUnitAssertionsShouldIncludeMessageRule() { + public UnitTestAssertionsShouldIncludeMessageRule() { super(ASTMethodCall.class); } diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 150725b5cb..ce67924d9d 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -885,20 +885,25 @@ class MyTest { // not public, that's fine - + + + message="Unit test assertions should include a message" + class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnitTestAssertionsShouldIncludeMessageRule" + externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unittestassertionsshouldincludemessage"> -JUnit assertions should include an informative message - i.e., use the three-argument version of +Unit assertions should include an informative message - i.e., use the three-argument version of assertEquals(), not the two-argument version. + +This rule supports tests using JUnit (3, 4 and 5) and TestNg. 3