Rename JUnitAssertionsShouldIncludeMessageRule

- The rule is now called UnitTestAssertionsShouldIncludeMessageRule as
   it applies to JUnit and TestNG.
 - The doc is updated to reflect this.
This commit is contained in:
Juan Martín Sotuyo Dodero
2024-04-17 16:15:06 -03:00
parent 691731cdd4
commit 5301a8e852
4 changed files with 14 additions and 9 deletions

View File

@ -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);
}

View File

@ -885,20 +885,25 @@ class MyTest { // not public, that's fine
</example>
</rule>
<rule name="JUnitAssertionsShouldIncludeMessage"
<rule name="JUnitAssertionsShouldIncludeMessage" deprecated="true" ref="UnitTestAssertionsShouldIncludeMessage" />
<rule name="UnitTestAssertionsShouldIncludeMessage"
language="java"
since="1.04"
message="JUnit assertions should include a message"
class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitAssertionsShouldIncludeMessageRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junitassertionsshouldincludemessage">
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">
<description>
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.
</description>
<priority>3</priority>
<example>
<![CDATA[
public class Foo extends TestCase {
public class Foo {
@Test
public void testSomething() {
assertEquals("foo", "bar");
// Use the form:

View File

@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.bestpractices;
import net.sourceforge.pmd.test.PmdRuleTst;
class JUnitAssertionsShouldIncludeMessageTest extends PmdRuleTst {
class UnitTestAssertionsShouldIncludeMessageTest extends PmdRuleTst {
// no additional unit tests
}