    1   /***
    2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
    3    */
    4   package test.net.sourceforge.pmd.rules.junit;
    5
    6   import net.sourceforge.pmd.PMD;
    7   import net.sourceforge.pmd.Rule;
    8   import net.sourceforge.pmd.RuleSetNotFoundException;
    9   import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
    10  import test.net.sourceforge.pmd.testframework.TestDescriptor;
    11
    12  public class JUnitSpellingRuleTest extends SimpleAggregatorTst {
    13
    14      private Rule rule;
    15
    16      public void setUp() throws RuleSetNotFoundException {
    17          rule = findRule("junit", "JUnitSpelling");
    18      }
    19
    20      public void testAll() {
    21          runTests(new TestDescriptor[]{
    22              new TestDescriptor(TEST1, "setUp mispellings", 2, rule),
    23              new TestDescriptor(TEST2, "tearDown mispellings", 2, rule),
    24              new TestDescriptor(TEST3, "ok", 0, rule),
    25              new TestDescriptor(TEST4, "unrelated methods", 0, rule),
    26              new TestDescriptor(TEST5, "overloaded setUp", 0, rule),
    27          });
    28      }
    29
    30      private static final String TEST1 =
    31              "public class Foo {" + PMD.EOL +
    32              " public void setup() {}" + PMD.EOL +
    33              " public void SetUp() {}" + PMD.EOL +
    34              "}";
    35
    36      private static final String TEST2 =
    37              "public class Foo {" + PMD.EOL +
    38              " public void TearDown() {}" + PMD.EOL +
    39              " public void teardown() {}" + PMD.EOL +
    40              "}";
    41
    42      private static final String TEST3 =
    43              "public class Foo {" + PMD.EOL +
    44              " public void setUp() {}" + PMD.EOL +
    45              " public void tearDown() {}" + PMD.EOL +
    46              "}";
    47
    48      private static final String TEST4 =
    49              "public class Foo {" + PMD.EOL +
    50              " public void utility() {}" + PMD.EOL +
    51              " public void foobr() {}" + PMD.EOL +
    52              "}";
    53
    54      private static final String TEST5 =
    55              "public class Foo {" + PMD.EOL +
    56              " public void setup(String x) {}" + PMD.EOL +
    57              "}";
    58  }