OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / libcore / junit / src / main / java / junit / extensions / RepeatedTest.java
1 package junit.extensions;
2
3 import junit.framework.*;
4
5 /**
6  * A Decorator that runs a test repeatedly.
7  *
8  */
9 public class RepeatedTest extends  TestDecorator {
10     private int fTimesRepeat;
11
12     public RepeatedTest(Test test, int repeat) {
13         super(test);
14         if (repeat < 0)
15             throw new IllegalArgumentException("Repetition count must be > 0");
16         fTimesRepeat= repeat;
17     }
18     public int countTestCases() {
19         return super.countTestCases()*fTimesRepeat;
20     }
21     public void run(TestResult result) {
22         for (int i= 0; i < fTimesRepeat; i++) {
23             if (result.shouldStop())
24                 break;
25             super.run(result);
26         }
27     }
28     public String toString() {
29         return super.toString()+"(repeated)";
30     }
31 }