KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > junit > tests > extensions > RepeatedTestTest


1 package junit.tests.extensions;
2
3 import junit.framework.*;
4 import junit.extensions.RepeatedTest;
5
6 /**
7  * Testing the RepeatedTest support.
8  */

9
10 public class RepeatedTestTest extends TestCase {
11     private TestSuite fSuite;
12
13     public static class SuccessTest extends TestCase {
14
15         public void runTest() {
16         }
17     }
18
19     public RepeatedTestTest(String JavaDoc name) {
20         super(name);
21         fSuite= new TestSuite();
22         fSuite.addTest(new SuccessTest());
23         fSuite.addTest(new SuccessTest());
24     }
25
26     public void testRepeatedOnce() {
27         Test test= new RepeatedTest(fSuite, 1);
28         assertEquals(2, test.countTestCases());
29         TestResult result= new TestResult();
30         test.run(result);
31         assertEquals(2, result.runCount());
32     }
33
34     public void testRepeatedMoreThanOnce() {
35         Test test= new RepeatedTest(fSuite, 3);
36         assertEquals(6, test.countTestCases());
37         TestResult result= new TestResult();
38         test.run(result);
39         assertEquals(6, result.runCount());
40     }
41
42     public void testRepeatedZero() {
43         Test test= new RepeatedTest(fSuite, 0);
44         assertEquals(0, test.countTestCases());
45         TestResult result= new TestResult();
46         test.run(result);
47         assertEquals(0, result.runCount());
48     }
49
50     public void testRepeatedNegative() {
51         try {
52             new RepeatedTest(fSuite, -1);
53         } catch (IllegalArgumentException JavaDoc e) {
54             return;
55         }
56         fail("Should throw an IllegalArgumentException");
57     }
58 }
Popular Tags