01: /* TestRunner.java */
02:
03: package org.quilt.textui;
04:
05: import java.util.Vector;
06:
07: import org.quilt.cover.stmt.StmtRegistry;
08: import org.quilt.framework.QuiltTest;
09: import org.quilt.reports.*;
10: import org.quilt.runner.*;
11:
12: /** Text-interface test runner for Quilt. */
13:
14: public class TestRunner extends Textui implements RunnerConst {
15:
16: public TestRunner() {
17: }
18:
19: public static void main(String[] args) {
20: System.exit(new TestRunner().handleArgs(args));
21: }
22:
23: /**
24: * Run an individual test.
25: *
26: * @param qt Quilt test descriptor.
27: * @param myFormatters Formatters pulled off the command line.
28: */
29: int runWithIt(QuiltTest qt, Vector myFormatters) {
30: // DEBUG
31: System.out.println("TestRunner.runWithIt - test "
32: + qt.getName());
33: // END
34: int fmtCount = myFormatters.size();
35: Runner runner;
36: if (quiltLoader == null) {
37: runner = new BaseTestRunner(qt);
38: } else {
39: runner = new BaseTestRunner(qt, quiltLoader);
40: }
41: for (int i = 0; i < myFormatters.size(); i++) {
42: // it would be cruel to make this a one-liner ;-)
43: FmtSelector fs = (FmtSelector) myFormatters.elementAt(i);
44: runner.addFormatter((Formatter) fs.createFormatter());
45: }
46: runner.run();
47: if (quiltLoader != null) {
48: if (stmtReg == null) {
49: System.out
50: .println("TestRunner.runWithIt INTERNAL ERROR: "
51: + "no StmtRegistry found");
52: } else {
53: System.out.println(stmtReg.getReport());
54: }
55: }
56: return runner.getRetCode();
57: }
58: }
|