01: package junit.tests.extensions;
02:
03: import junit.extensions.RepeatedTest;
04: import junit.framework.Test;
05: import junit.framework.TestCase;
06: import junit.framework.TestResult;
07: import junit.framework.TestSuite;
08:
09: /**
10: * Testing the RepeatedTest support.
11: */
12:
13: public class RepeatedTestTest extends TestCase {
14: private TestSuite fSuite;
15:
16: public static class SuccessTest extends TestCase {
17:
18: @Override
19: public void runTest() {
20: }
21: }
22:
23: public RepeatedTestTest(String name) {
24: super (name);
25: fSuite = new TestSuite();
26: fSuite.addTest(new SuccessTest());
27: fSuite.addTest(new SuccessTest());
28: }
29:
30: public void testRepeatedOnce() {
31: Test test = new RepeatedTest(fSuite, 1);
32: assertEquals(2, test.countTestCases());
33: TestResult result = new TestResult();
34: test.run(result);
35: assertEquals(2, result.runCount());
36: }
37:
38: public void testRepeatedMoreThanOnce() {
39: Test test = new RepeatedTest(fSuite, 3);
40: assertEquals(6, test.countTestCases());
41: TestResult result = new TestResult();
42: test.run(result);
43: assertEquals(6, result.runCount());
44: }
45:
46: public void testRepeatedZero() {
47: Test test = new RepeatedTest(fSuite, 0);
48: assertEquals(0, test.countTestCases());
49: TestResult result = new TestResult();
50: test.run(result);
51: assertEquals(0, result.runCount());
52: }
53:
54: public void testRepeatedNegative() {
55: try {
56: new RepeatedTest(fSuite, -1);
57: } catch (IllegalArgumentException e) {
58: assertTrue(e.getMessage().contains(">="));
59: return;
60: }
61: fail("Should throw an IllegalArgumentException");
62: }
63: }
|