diff --git a/docs/pages/pmd/rules/java/bestpractices.md b/docs/pages/pmd/rules/java/bestpractices.md index 380663a00d..896c9b4c74 100644 --- a/docs/pages/pmd/rules/java/bestpractices.md +++ b/docs/pages/pmd/rules/java/bestpractices.md @@ -564,8 +564,12 @@ In JUnit 4, only methods annotated with the @Test annotation are executed. **This rule is defined by the following XPath expression:** ``` -//ClassOrInterfaceBodyDeclaration[MethodDeclaration[@Public='true']/MethodDeclarator[starts-with(@Image,'test')]] -[count(Annotation//Name[@Image='Test'])=0] +//ClassOrInterfaceDeclaration[ + matches(@Image, $testClassPattern) + or ExtendsList/ClassOrInterfaceType[pmd-java:typeof(@Image, 'junit.framework.TestCase', 'TestCase')]] + + /ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration[MethodDeclaration[@Public=true()]/MethodDeclarator[starts-with(@Image, 'test')]] + [not(Annotation//Name[pmd-java:typeof(@Image, 'org.junit.Test', 'Test')])] ``` **Example(s):** @@ -583,6 +587,12 @@ public class MyTest { } ``` +**This rule has the following properties:** + +|Name|Default Value|Description|Multivalued| +|----|-------------|-----------|-----------| +|testClassPattern|Test|The regex pattern used to identify test classes|no| + **Use this rule by referencing it:** ``` xml