Class RuleTst
- java.lang.Object
-
- net.sourceforge.pmd.testframework.RuleTst
-
- Direct Known Subclasses:
SimpleAggregatorTst
public abstract class RuleTst extends java.lang.Object
Advanced methods for test cases
-
-
Constructor Summary
Constructors Constructor Description RuleTst()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TestDescriptor[]
extractTestsFromXml(net.sourceforge.pmd.Rule rule)
Extract a set of tests from an XML file.TestDescriptor[]
extractTestsFromXml(net.sourceforge.pmd.Rule rule, java.lang.String testsFileName)
TestDescriptor[]
extractTestsFromXml(net.sourceforge.pmd.Rule rule, java.lang.String testsFileName, java.lang.String baseDirectory)
Extract a set of tests from an XML file with the given name.net.sourceforge.pmd.Rule
findRule(java.lang.String ruleSet, java.lang.String ruleName)
Find a rule in a certain ruleset by nameprotected java.lang.String
getCleanRuleName(net.sourceforge.pmd.Rule rule)
getResourceAsStream tries to find the XML file in weird locations if the ruleName includes the package, so we strip it here.protected net.sourceforge.pmd.Rule
reinitializeRule(net.sourceforge.pmd.Rule rule)
Code to be executed if the rule is reinitialised.void
runTest(TestDescriptor test)
Run the rule on the given code, and check the expected number of violations.void
runTestFromString(java.lang.String code, net.sourceforge.pmd.Rule rule, net.sourceforge.pmd.Report report, net.sourceforge.pmd.lang.LanguageVersion languageVersion)
Run the rule on the given code and put the violations in the report.void
runTestFromString(java.lang.String code, net.sourceforge.pmd.Rule rule, net.sourceforge.pmd.Report report, net.sourceforge.pmd.lang.LanguageVersion languageVersion, boolean isUseAuxClasspath)
void
runTestFromString(TestDescriptor test, net.sourceforge.pmd.Rule rule, net.sourceforge.pmd.Report report)
-
-
-
Method Detail
-
findRule
public net.sourceforge.pmd.Rule findRule(java.lang.String ruleSet, java.lang.String ruleName)
Find a rule in a certain ruleset by name
-
runTest
public void runTest(TestDescriptor test)
Run the rule on the given code, and check the expected number of violations.
-
reinitializeRule
protected net.sourceforge.pmd.Rule reinitializeRule(net.sourceforge.pmd.Rule rule)
Code to be executed if the rule is reinitialised.- Parameters:
rule
- The rule to reinitialise- Returns:
- The rule once it has been reinitialised
-
runTestFromString
public void runTestFromString(java.lang.String code, net.sourceforge.pmd.Rule rule, net.sourceforge.pmd.Report report, net.sourceforge.pmd.lang.LanguageVersion languageVersion)
Run the rule on the given code and put the violations in the report.
-
runTestFromString
public void runTestFromString(java.lang.String code, net.sourceforge.pmd.Rule rule, net.sourceforge.pmd.Report report, net.sourceforge.pmd.lang.LanguageVersion languageVersion, boolean isUseAuxClasspath)
-
runTestFromString
public void runTestFromString(TestDescriptor test, net.sourceforge.pmd.Rule rule, net.sourceforge.pmd.Report report)
-
getCleanRuleName
protected java.lang.String getCleanRuleName(net.sourceforge.pmd.Rule rule)
getResourceAsStream tries to find the XML file in weird locations if the ruleName includes the package, so we strip it here.
-
extractTestsFromXml
public TestDescriptor[] extractTestsFromXml(net.sourceforge.pmd.Rule rule)
Extract a set of tests from an XML file. The file should be ./xml/RuleName.xml relative to the test class. The format is defined in test-data.xsd.
-
extractTestsFromXml
public TestDescriptor[] extractTestsFromXml(net.sourceforge.pmd.Rule rule, java.lang.String testsFileName)
-
extractTestsFromXml
public TestDescriptor[] extractTestsFromXml(net.sourceforge.pmd.Rule rule, java.lang.String testsFileName, java.lang.String baseDirectory)
Extract a set of tests from an XML file with the given name. The file should be ./xml/[testsFileName].xml relative to the test class. The format is defined in test-data.xsd.
-
-