From 07648381ffc850ae899d38adf9035afc30dc920c Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Thu, 8 May 2003 19:43:59 +0000 Subject: [PATCH] More test cleanups git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1897 51baf565-9d33-0410-a72c-fc3788e3496d --- .../ForLoopShouldBeWhileLoopRuleTest.java | 40 +++++++++---------- .../rules/ForLoopsMustUseBracesRuleTest.java | 28 +++++-------- .../IfElseStmtsMustUseBracesRuleTest.java | 30 +++++++------- 3 files changed, 43 insertions(+), 55 deletions(-) diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopShouldBeWhileLoopRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopShouldBeWhileLoopRuleTest.java index 8c13430da3..67c52de3f7 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopShouldBeWhileLoopRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopShouldBeWhileLoopRuleTest.java @@ -4,7 +4,24 @@ import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.XPathRule; -public class ForLoopShouldBeWhileLoopRuleTest extends RuleTst { +public class ForLoopShouldBeWhileLoopRuleTest extends SimpleAggregatorTst { + + private Rule rule; + + public void setUp() { + rule = new XPathRule(); + rule.addProperty( + "xpath", + "//ForStatement[count(*) > 1][not(ForInit)][not(ForUpdate)]"); + } + + public void testAll() { + runTests(new TestDescriptor[] { + new TestDescriptor(TEST1, "simple failure case", 1, rule), + new TestDescriptor(TEST2, "ok", 0, rule), + new TestDescriptor(TEST3, "for loop like this: for (;;) {} ", 0, rule), + }); + } private static final String TEST1 = "public class ForLoopShouldBeWhileLoop1 {" + CPD.EOL + @@ -32,25 +49,4 @@ public class ForLoopShouldBeWhileLoopRuleTest extends RuleTst { " }" + CPD.EOL + "}"; - - private Rule rule; - - public void setUp() { - rule = new XPathRule(); - rule.addProperty( - "xpath", - "//ForStatement[count(*) > 1][not(ForInit)][not(ForUpdate)]"); - } - - public void testSimple() throws Throwable { - runTestFromString(TEST1, 1, rule); - } - - public void testOK() throws Throwable { - runTestFromString(TEST2, 0, rule); - } - - public void testForSemicolonSemicolon() throws Throwable { - runTestFromString(TEST3, 0, rule); - } } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java index 35e2154459..e0bd38d3c3 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRuleTest.java @@ -4,7 +4,7 @@ import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.XPathRule; -public class ForLoopsMustUseBracesRuleTest extends RuleTst { +public class ForLoopsMustUseBracesRuleTest extends SimpleAggregatorTst { private Rule rule; @@ -12,20 +12,15 @@ public class ForLoopsMustUseBracesRuleTest extends RuleTst { rule = new XPathRule(); rule.addProperty("xpath", "//ForStatement[not(Statement/Block)]"); } - 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,1, rule); - } - public void test4() throws Throwable { - runTestFromString(TEST4,1, rule); - } - public void test5() throws Throwable { - runTestFromString(TEST5,1, rule); + + public void testAll() { + runTests(new TestDescriptor[] { + new TestDescriptor(TEST1, "simple failure case", 1, rule), + new TestDescriptor(TEST2, "ok", 0, rule), + new TestDescriptor(TEST3, "", 1, rule), + new TestDescriptor(TEST4, "", 1, rule), + new TestDescriptor(TEST5, "", 1, rule), + }); } private static final String TEST1 = @@ -50,7 +45,6 @@ public class ForLoopsMustUseBracesRuleTest extends RuleTst { " public void foo() { " + CPD.EOL + " for (int i=0; i<42;) " + CPD.EOL + " foo();" + CPD.EOL + - " " + CPD.EOL + " }" + CPD.EOL + "}"; @@ -59,7 +53,6 @@ public class ForLoopsMustUseBracesRuleTest extends RuleTst { " public void foo() { " + CPD.EOL + " for (int i=0;;) " + CPD.EOL + " foo();" + CPD.EOL + - " " + CPD.EOL + " }" + CPD.EOL + "}"; @@ -68,7 +61,6 @@ public class ForLoopsMustUseBracesRuleTest extends RuleTst { " public void foo() { " + CPD.EOL + " for (;;) " + CPD.EOL + " foo();" + CPD.EOL + - " " + CPD.EOL + " }" + CPD.EOL + "}"; } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java index a73da8db74..8d5731bed0 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/IfElseStmtsMustUseBracesRuleTest.java @@ -4,7 +4,21 @@ import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.cpd.CPD; import net.sourceforge.pmd.rules.XPathRule; -public class IfElseStmtsMustUseBracesRuleTest extends RuleTst { +public class IfElseStmtsMustUseBracesRuleTest extends SimpleAggregatorTst { + + private Rule rule; + + public void setUp() { + rule = new XPathRule(); + rule.addProperty("xpath", "//IfStatement[count(*) > 2][not(Statement/Block)]"); + } + + public void testAll() { + runTests(new TestDescriptor[] { + new TestDescriptor(TEST1, "simple failure case", 1, rule), + new TestDescriptor(TEST2, "ok", 0, rule), + }); + } private static final String TEST1 = "public class IfElseStmtsNeedBraces1 {" + CPD.EOL + @@ -32,18 +46,4 @@ public class IfElseStmtsMustUseBracesRuleTest extends RuleTst { - private Rule rule; - - public void setUp() { - rule = new XPathRule(); - rule.addProperty("xpath", "//IfStatement[count(*) > 2][not(Statement/Block)]"); - } - - public void testIfElseStmtsMustUseBraces1() throws Throwable { - runTestFromString(TEST1, 1, rule); - } - - public void testIfElseStmtsMustUseBraces2() throws Throwable { - runTestFromString(TEST2, 0, rule); - } }