1 /**
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package test.net.sourceforge.pmd.testframework;
5
6 import java.util.Properties;
7
8 import net.sourceforge.pmd.Rule;
9 import net.sourceforge.pmd.SourceType;
10
11 /**
12 * Stores the information required to run a complete test.
13 */
14 public class TestDescriptor {
15 private Rule rule;
16 private Properties properties;
17 private String description;
18 private int numberOfProblemsExpected;
19 private String code;
20 private SourceType sourceType;
21 private boolean reinitializeRule = false;
22 private boolean isRegressionTest = true;
23
24 public TestDescriptor(String code, String description, int numberOfProblemsExpected, Rule rule) {
25 this(code, description, numberOfProblemsExpected, rule, RuleTst.DEFAULT_SOURCE_TYPE);
26 }
27
28 public TestDescriptor(String code, String description, int numberOfProblemsExpected, Rule rule, SourceType sourceType) {
29 this.rule = rule;
30 this.code = code;
31 this.description = description;
32 this.numberOfProblemsExpected = numberOfProblemsExpected;
33 this.sourceType = sourceType;
34 }
35
36 public void setProperties(Properties properties) {
37 this.properties = properties;
38 }
39
40 public Properties getProperties() {
41 return properties;
42 }
43
44 public String getCode() {
45 return code;
46 }
47
48 public SourceType getSourceType() {
49 return sourceType;
50 }
51
52 public String getDescription() {
53 return description;
54 }
55
56 public int getNumberOfProblemsExpected() {
57 return numberOfProblemsExpected;
58 }
59
60 public Rule getRule() {
61 return rule;
62 }
63
64 public boolean getReinitializeRule() {
65 return reinitializeRule;
66 }
67
68 public void setReinitializeRule(boolean reinitializeRule) {
69 this.reinitializeRule = reinitializeRule;
70 }
71
72 /**
73 * Checks whether we are testing for regression problems only.
74 * Return value is based on the system property "pmd.regress".
75 *
76 * @return <code>true</code> if system property "pmd.regress" is set to <code>true</code>, <code>false</code> otherwise
77 */
78 public static boolean inRegressionTestMode() {
79
80 return Boolean.getBoolean("pmd.regress");
81 }
82
83 public boolean isRegressionTest() {
84 return isRegressionTest;
85 }
86
87 public void setRegressionTest(boolean isRegressionTest) {
88 this.isRegressionTest = isRegressionTest;
89 }
90 }