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:
12: private Counts pageCounts = new Counts();
13:
14: public StandardResultHandler(PrintStream output) {
15: this .output = output;
16: }
17:
18: public void acceptResult(PageResult result) throws Exception {
19: Counts counts = result.counts();
20: pageCounts.tallyPageCounts(counts);
21: for (int i = 0; i < counts.right; i++)
22: output.print(".");
23: if (counts.wrong > 0 || counts.exceptions > 0) {
24: output.println();
25: if (counts.wrong > 0)
26: output.println(pageDescription(result)
27: + " has failures");
28: if (counts.exceptions > 0)
29: output.println(pageDescription(result) + " has errors");
30: }
31: }
32:
33: private String pageDescription(PageResult result) {
34: String description = result.title();
35: if ("".equals(description))
36: description = "The test";
37: return description;
38: }
39:
40: public void acceptFinalCount(Counts count) throws Exception {
41: output.println();
42: output.println("Test Pages: " + pageCounts);
43: output.println("Assertions: " + count);
44: }
45:
46: public int getByteCount() {
47: return 0;
48: }
49:
50: public InputStream getResultStream() throws Exception {
51: return null;
52: }
53: }
|