|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
RepeatHelper.java | 0% | 0% | 0% | 0% |
|
1 |
package junit.extensions.abbot;
|
|
2 |
|
|
3 |
import java.util.ArrayList;
|
|
4 |
|
|
5 |
import junit.extensions.RepeatedTest;
|
|
6 |
import junit.framework.*;
|
|
7 |
|
|
8 |
import abbot.Log;
|
|
9 |
|
|
10 |
/** Convenience functions to wrap a given test case such that individual
|
|
11 |
methods may be run with heavy repetition, and default suites run with
|
|
12 |
light repetition.
|
|
13 |
*/
|
|
14 |
|
|
15 |
public class RepeatHelper extends TestHelper { |
|
16 |
|
|
17 |
private static int repeatCount = 1; |
|
18 |
|
|
19 |
// no instantiations
|
|
20 | 0 |
protected RepeatHelper() { }
|
21 |
|
|
22 | 0 |
protected static String[] parseArgs(String[] args) { |
23 | 0 |
ArrayList list = new ArrayList();
|
24 | 0 |
for (int i=0;i < args.length;i++) { |
25 | 0 |
try {
|
26 | 0 |
repeatCount = Integer.parseInt(args[i]); |
27 |
} |
|
28 |
catch(NumberFormatException e) {
|
|
29 | 0 |
list.add(args[i]); |
30 |
} |
|
31 |
} |
|
32 | 0 |
return (String[])list.toArray(new String[list.size()]); |
33 |
} |
|
34 |
|
|
35 | 0 |
public static void runTests(String[] args, Class testClass) { |
36 | 0 |
args = Log.init(args); |
37 | 0 |
args = parseArgs(args); |
38 | 0 |
args = TestHelper.parseArgs(args); |
39 | 0 |
try {
|
40 | 0 |
Test test = collectTests(args, testClass); |
41 | 0 |
if (repeatCount > 1)
|
42 | 0 |
test = new RepeatedTest(test, repeatCount);
|
43 | 0 |
runTest(test); |
44 |
} |
|
45 |
catch(Exception e) {
|
|
46 | 0 |
System.err.println(e.getMessage()); |
47 | 0 |
System.exit(-2); |
48 |
} |
|
49 |
} |
|
50 |
} |
|
51 |
|
|