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