Package org.codenarc.rule
Class AbstractRuleTestCase<T extends Rule>
- java.lang.Object
-
- org.codenarc.test.AbstractTestCase
-
- org.codenarc.rule.AbstractRuleTestCase<T>
-
- All Implemented Interfaces:
groovy.lang.GroovyObject
public abstract class AbstractRuleTestCase<T extends Rule> extends AbstractTestCase
-
-
Field Summary
Fields Modifier and Type Field Description protected static ObjectCONSTRUCTOR_METHOD_NAMEprotected static ObjectDEFAULT_TEST_CLASS_NAMESprotected static ObjectDEFAULT_TEST_FILESprotected Truleprotected StringsourceCodeNameprotected StringsourceCodePath-
Fields inherited from class org.codenarc.test.AbstractTestCase
CODENARC_PROPERTIES_FILE_PROP, LOG, testName
-
-
Constructor Summary
Constructors Constructor Description AbstractRuleTestCase()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ListapplyRuleTo(String source)protected voidassertInlineViolations(String annotatedSource)protected voidassertNoViolations(String source)protected voidassertSingleViolation(String source)protected voidassertSingleViolation(String source, groovy.lang.Closure closure)protected voidassertSingleViolation(String source, Integer lineNumber)protected voidassertSingleViolation(String source, Integer lineNumber, String sourceLineText)protected voidassertSingleViolation(String source, Integer lineNumber, String sourceLineText, Object messageText)protected voidassertTwoViolations(String source, Integer lineNumber1, String sourceLineText1, Integer lineNumber2, String sourceLineText2)protected voidassertTwoViolations(String source, Integer lineNumber1, String sourceLineText1, Object msg1, Integer lineNumber2, String sourceLineText2, Object msg2)protected voidassertViolation(Violation violation, Integer lineNumber, String sourceLineText)protected voidassertViolation(Violation violation, Integer lineNumber, String sourceLineText, Object messageText)protected voidassertViolations(String source, Map... violationMaps)protected abstract TcreateRule()groovy.lang.MetaClassgetMetaClass()ObjectgetProperty(String property)protected static StringinlineViolation(String violationMessage)ObjectinvokeMethod(String method, Object arguments)protected ListmanuallyApplyRule(String source)protected static StringremoveInlineViolations(String annotatedSource)voidsetMetaClass(groovy.lang.MetaClass mc)voidsetProperty(String property, Object value)voidsetUpAbstractRuleTestCase()voidtestThatApplyToFilesMatchingValuesAreValidRegex()voidtestThatInvalidCodeHasNoViolations()voidtestThatUnrelatedCodeHasNoViolations()-
Methods inherited from class org.codenarc.test.AbstractTestCase
getName, log, setUpAbstractTestCase
-
-
-
-
Field Detail
-
CONSTRUCTOR_METHOD_NAME
protected static final Object CONSTRUCTOR_METHOD_NAME
-
DEFAULT_TEST_FILES
protected static final Object DEFAULT_TEST_FILES
-
DEFAULT_TEST_CLASS_NAMES
protected static final Object DEFAULT_TEST_CLASS_NAMES
-
sourceCodeName
protected String sourceCodeName
-
sourceCodePath
protected String sourceCodePath
-
-
Method Detail
-
assertSingleViolation
protected void assertSingleViolation(String source, Integer lineNumber, String sourceLineText)
-
assertSingleViolation
protected void assertSingleViolation(String source)
-
assertViolation
protected void assertViolation(Violation violation, Integer lineNumber, String sourceLineText)
-
getMetaClass
public groovy.lang.MetaClass getMetaClass()
- Specified by:
getMetaClassin interfacegroovy.lang.GroovyObject- Overrides:
getMetaClassin classAbstractTestCase
-
setMetaClass
public void setMetaClass(groovy.lang.MetaClass mc)
- Specified by:
setMetaClassin interfacegroovy.lang.GroovyObject- Overrides:
setMetaClassin classAbstractTestCase
-
invokeMethod
public Object invokeMethod(String method, Object arguments)
- Specified by:
invokeMethodin interfacegroovy.lang.GroovyObject- Overrides:
invokeMethodin classAbstractTestCase
-
getProperty
public Object getProperty(String property)
- Specified by:
getPropertyin interfacegroovy.lang.GroovyObject- Overrides:
getPropertyin classAbstractTestCase
-
setProperty
public void setProperty(String property, Object value)
- Specified by:
setPropertyin interfacegroovy.lang.GroovyObject- Overrides:
setPropertyin classAbstractTestCase
-
testThatUnrelatedCodeHasNoViolations
public void testThatUnrelatedCodeHasNoViolations()
-
testThatInvalidCodeHasNoViolations
public void testThatInvalidCodeHasNoViolations()
-
testThatApplyToFilesMatchingValuesAreValidRegex
public void testThatApplyToFilesMatchingValuesAreValidRegex()
-
createRule
protected abstract T createRule()
-
assertTwoViolations
protected void assertTwoViolations(String source, Integer lineNumber1, String sourceLineText1, Integer lineNumber2, String sourceLineText2)
-
assertInlineViolations
protected void assertInlineViolations(String annotatedSource)
-
assertTwoViolations
protected void assertTwoViolations(String source, Integer lineNumber1, String sourceLineText1, Object msg1, Integer lineNumber2, String sourceLineText2, Object msg2)
-
assertSingleViolation
protected void assertSingleViolation(String source, Integer lineNumber, String sourceLineText, Object messageText)
-
assertSingleViolation
protected void assertSingleViolation(String source, groovy.lang.Closure closure)
-
assertNoViolations
protected void assertNoViolations(String source)
-
assertViolation
protected void assertViolation(Violation violation, Integer lineNumber, String sourceLineText, Object messageText)
-
setUpAbstractRuleTestCase
public void setUpAbstractRuleTestCase()
-
-