summaryrefslogtreecommitdiff
path: root/dx/src/junit/extensions/RepeatedTest.java
blob: ebce7754738266e254cff4ac6a1a48927f5bfe72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package junit.extensions;

import junit.framework.*;

/**
 * A Decorator that runs a test repeatedly.
 *
 */
public class RepeatedTest extends  TestDecorator {
	private int fTimesRepeat;

	public RepeatedTest(Test test, int repeat) {
		super(test);
		if (repeat < 0)
			throw new IllegalArgumentException("Repetition count must be > 0");
		fTimesRepeat= repeat;
	}
	public int countTestCases() {
		return super.countTestCases()*fTimesRepeat;
	}
	public void run(TestResult result) {
		for (int i= 0; i < fTimesRepeat; i++) {
			if (result.shouldStop())
				break;
			super.run(result);
		}
	}
	public String toString() {
		return super.toString()+"(repeated)";
	}
}