01: package junit.extensions.abbot;
02:
03: import java.util.ArrayList;
04:
05: import junit.extensions.RepeatedTest;
06: import junit.framework.*;
07:
08: import abbot.Log;
09:
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: protected RepeatHelper() {
21: }
22:
23: protected static String[] parseArgs(String[] args) {
24: ArrayList list = new ArrayList();
25: for (int i = 0; i < args.length; i++) {
26: try {
27: repeatCount = Integer.parseInt(args[i]);
28: } catch (NumberFormatException e) {
29: list.add(args[i]);
30: }
31: }
32: return (String[]) list.toArray(new String[list.size()]);
33: }
34:
35: public static void runTests(String[] args, Class testClass) {
36: args = Log.init(args);
37: args = parseArgs(args);
38: args = TestHelper.parseArgs(args);
39: try {
40: Test test = collectTests(args, testClass);
41: if (repeatCount > 1)
42: test = new RepeatedTest(test, repeatCount);
43: runTest(test);
44: } catch (Exception e) {
45: System.err.println(e.getMessage());
46: System.exit(-2);
47: }
48: }
49: }
|