From 1daa5fd737780404233bd58be3c98c05bed9f70c Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Tue, 29 Apr 2003 16:10:56 +0000 Subject: [PATCH] Test code refactorings git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1877 51baf565-9d33-0410-a72c-fc3788e3496d --- .../rules/UnusedFormalParameterRuleTest.java | 37 ++++++++--------- .../pmd/rules/UnusedImportsRuleTest.java | 40 ++++++++----------- 2 files changed, 34 insertions(+), 43 deletions(-) diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedFormalParameterRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedFormalParameterRuleTest.java index 58cbf17011..aa9cd3127c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedFormalParameterRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedFormalParameterRuleTest.java @@ -3,7 +3,23 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.UnusedFormalParameterRule; -public class UnusedFormalParameterRuleTest extends RuleTst { +public class UnusedFormalParameterRuleTest extends SimpleAggregatorTst { + + private UnusedFormalParameterRule rule; + + public void setUp() { + rule = new UnusedFormalParameterRule(); + rule.setMessage("Avoid this stuff -> ''{0}''"); + } + + public void testAll() { + runTests(new TestDescriptor[] { + new TestDescriptor(TEST1, "one parameter", 1, rule), + new TestDescriptor(TEST2, "fully qualified parameter", 0, rule), + new TestDescriptor(TEST3, "one parameter with a method call", 0, rule), + new TestDescriptor(TEST4, "interface", 0, rule) + }); + } private static final String TEST1 = "class UnusedFormalParam1 {" + CPD.EOL + @@ -30,23 +46,4 @@ public class UnusedFormalParameterRuleTest extends RuleTst { " public void foo(String bar);" + CPD.EOL + "}"; - private UnusedFormalParameterRule rule; - - public void setUp() { - rule = new UnusedFormalParameterRule(); - rule.setMessage("Avoid this stuff -> ''{0}''"); - } - - public void testOneParam() throws Throwable { - runTestFromString(TEST1, 1, rule); - } - public void testFullyQualified() throws Throwable { - runTestFromString(TEST2, 0, rule); - } - public void testOneParamWithMethodCall() throws Throwable { - runTestFromString(TEST3, 0, rule); - } - public void testInterface() throws Throwable { - runTestFromString(TEST4, 0, rule); - } } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java index 792bbde36c..683abac0f5 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/UnusedImportsRuleTest.java @@ -3,7 +3,23 @@ package test.net.sourceforge.pmd.rules; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.UnusedImportsRule; -public class UnusedImportsRuleTest extends RuleTst { +public class UnusedImportsRuleTest extends SimpleAggregatorTst { + + private UnusedImportsRule rule; + + public void setUp() { + rule = new UnusedImportsRule(); + rule.setMessage("Avoid this stuff -> ''{0}''"); + } + + public void testAll() { + runTests(new TestDescriptor[] { + new TestDescriptor(TEST1, "simple unused single type import", 1, rule), + new TestDescriptor(TEST2, "one used single type import", 0, rule), + new TestDescriptor(TEST3, "2 unused single-type imports", 2, rule), + new TestDescriptor(TEST4, "1 used single type import", 0, rule) + }); + } private static final String TEST1 = "import java.io.File;" + CPD.EOL + @@ -30,26 +46,4 @@ public class UnusedImportsRuleTest extends RuleTst { "}"; - private UnusedImportsRule rule; - - public void setUp() { - rule = new UnusedImportsRule(); - rule.setMessage("Avoid this stuff -> ''{0}''"); - } - - public void test1() throws Throwable { - runTestFromString(TEST1, 1, rule); - } - - public void test2() throws Throwable { - runTestFromString(TEST2, 0, rule); - } - - public void test3() throws Throwable { - runTestFromString(TEST3, 2, rule); - } - - public void test4() throws Throwable { - runTestFromString(TEST4, 0, rule); - } }