org.codenarc.rule.junit
Class JUnitPublicNonTestMethodRule
java.lang.Object
org.codenarc.rule.AbstractRule
org.codenarc.rule.AbstractAstVisitorRule
org.codenarc.rule.junit.JUnitPublicNonTestMethodRule
class JUnitPublicNonTestMethodRule
extends AbstractAstVisitorRule
Rule that checks if a JUnit test class contains public methods other than:
- Zero-argument methods with names starting with "test"
- The setUp() and tearDown() methods
- Methods annotated with @Test
- Methods annotated with @Before and @After
- Methods annotated with @BeforeClass and @AfterClass
Public, non-test methods on a test class violate conventional usage of test classes,
and can be confusing.
Public, non-test methods may also hide unintentional 'Lost Tests'. For instance, the test method
declaration may accidentally include methods parameters, and thus be ignored by JUnit. Or the
method may accidentally not follow the "test.." naming convention and not have the @Test annotation,
and thus be ignored by JUnit.
This rule sets the default value of applyToFilesMatching
to only match source code file
paths ending in 'Test.groovy' or 'Tests.groovy'.
- author:
- Chris Mair
- version:
- $Revision: 163 $ - $Date: 2009-05-23 19:41:24 -0400 (Sat, 23 May 2009) $
Methods inherited from class AbstractRule
|
applyTo, createViolation, createViolation, createViolationForImport, createViolationForImport, getImportsSortedByLineNumber, getName, getPriority, packageNameForImport, setName, setPriority, sourceLineAndNumberForImport, sourceLineAndNumberForImport |
applyToClassNames
String applyToClassNames
-
astVisitorClass
Class astVisitorClass
-
name
String name
-
priority
int priority
-
JUnitPublicNonTestMethodRule
JUnitPublicNonTestMethodRule()
-
Groovy Documentation