Skip to content

Commit

Permalink
Added PMD tests for detecting misuse of TestClass and TestMethod, e.g…
Browse files Browse the repository at this point in the history
…. TestClass on a method. (fixes #3014808)
  • Loading branch information
egonw committed Jun 17, 2010
1 parent 9d679fe commit c94ebcf
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions pmd/customCDK.xml
Expand Up @@ -24,6 +24,44 @@
</properties> </properties>
</rule> </rule>


<rule name="TestClassAnnotationForMethod"
message="Methods should be annotated with TestMethod, not TestClass."
class="net.sourceforge.pmd.rules.XPathRule">
<description>
Detects methods annotated with @TestClass, where @TestMethod is supposed
to be used.
</description>
<priority>1</priority>
<properties>
<property name="xpath" pluginname="true">
<value>
<![CDATA[
//ClassOrInterfaceBodyDeclaration[count(Annotation//Name[@Image='TestClass'])=1]
]]>
</value>
</property>
</properties>
</rule>

<rule name="TestMethodAnnotationForClass"
message="Classes should be annotated with TestClass, not TestMethod."
class="net.sourceforge.pmd.rules.XPathRule">
<description>
Detects classes annotated with @TestMethod, where @TestClass is supposed
to be used.
</description>
<priority>1</priority>
<properties>
<property name="xpath" pluginname="true">
<value>
<![CDATA[
//ClassOrInterfaceBodyDeclaration[count(Annotation//Name[@Image='TestClass'])=1]
]]>
</value>
</property>
</properties>
</rule>

<!-- does not work yet... needs to be fixed <!-- does not work yet... needs to be fixed
rule name="CDK_MoreThanOneLoggingToolInstantiated" rule name="CDK_MoreThanOneLoggingToolInstantiated"
Expand Down

0 comments on commit c94ebcf

Please sign in to comment.