01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.runner;
04:
05: import java.io.*;
06: import fit.Counts;
07:
08: //TODO MDM Rename to VerboseResultHandler
09: public class StandardResultHandler implements ResultHandler {
10: private PrintStream output;
11: private Counts pageCounts = new Counts();
12:
13: public StandardResultHandler(PrintStream output) {
14: this .output = output;
15: }
16:
17: public void acceptResult(PageResult result) throws Exception {
18: Counts counts = result.counts();
19: pageCounts.tallyPageCounts(counts);
20: for (int i = 0; i < counts.right; i++)
21: output.print(".");
22: if (counts.wrong > 0 || counts.exceptions > 0) {
23: output.println();
24: if (counts.wrong > 0)
25: output.println(pageDescription(result)
26: + " has failures");
27: if (counts.exceptions > 0)
28: output.println(pageDescription(result) + " has errors");
29: }
30: }
31:
32: private String pageDescription(PageResult result) {
33: String description = result.title();
34: if ("".equals(description))
35: description = "The test";
36: return description;
37: }
38:
39: public void acceptFinalCount(Counts count) throws Exception {
40: output.println();
41: output.println("Test Pages: " + pageCounts);
42: output.println("Assertions: " + count);
43: }
44:
45: public int getByteCount() {
46: return 0;
47: }
48:
49: public InputStream getResultStream() throws Exception {
50: return null;
51: }
52: }
|