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.responders.run;
04:
05: import fitnesse.html.*;
06: import fitnesse.testutil.AbstractRegex;
07: import fit.Counts;
08:
09: public class SuiteHtmlFormatterTest extends AbstractRegex {
10: private HtmlPage page;
11:
12: private SuiteHtmlFormatter formatter;
13:
14: public void setUp() throws Exception {
15: page = new HtmlPageFactory().newPage();
16: formatter = new SuiteHtmlFormatter(page);
17: }
18:
19: public void tearDown() throws Exception {
20: }
21:
22: public void testTestSummary() throws Exception {
23: formatter.setPageAssertions(new Counts(12, 0, 0, 0));
24: String summary = formatter.testSummary(new Counts(49, 0, 0, 0));
25:
26: assertSubString(
27: "<strong>Test Pages:</strong> 12 right, 0 wrong, 0 ignored, 0 exceptions",
28: summary);
29: assertSubString(
30: "<strong>Assertions:</strong> 49 right, 0 wrong, 0 ignored, 0 exceptions",
31: summary);
32: }
33:
34: public void testCountsHtml() throws Exception {
35: String row1 = formatter.acceptResults("RelativePageName",
36: new Counts(1, 0, 0, 0));
37: String row2 = formatter.acceptResults("AnotherPageName",
38: new Counts(0, 1, 0, 0));
39:
40: assertSubString("<div class=\"alternating_row_2\">", row1);
41: assertSubString(
42: "<span class=\"test_summary_results pass\">1 right, 0 wrong, 0 ignored, 0 exceptions</span>",
43: row1);
44: assertSubString(
45: "<a href=\"#RelativePageName\" class=\"test_summary_link\">RelativePageName</a>",
46: row1);
47:
48: assertSubString("<div class=\"alternating_row_1\">", row2);
49: assertSubString(
50: "<span class=\"test_summary_results fail\">0 right, 1 wrong, 0 ignored, 0 exceptions</span>",
51: row2);
52: assertSubString(
53: "<a href=\"#AnotherPageName\" class=\"test_summary_link\">AnotherPageName</a>",
54: row2);
55: }
56:
57: public void testResultsHtml() throws Exception {
58: formatter.startOutputForNewTest("RelativeName", "FullName");
59: formatter.acceptOutput("starting");
60: formatter.acceptOutput(" output");
61: formatter.acceptResults("RelativeName", new Counts(1, 0, 0, 0));
62: formatter.startOutputForNewTest("NewRelativeName",
63: "NewFullName");
64: formatter.acceptOutput("second");
65: formatter.acceptOutput(" test");
66: formatter.acceptResults("NewRelativeName", new Counts(0, 1, 0,
67: 0));
68:
69: String results = formatter.testOutput();
70: assertSubString("<h2 class=\"centered\">Test Output</h2>",
71: results);
72:
73: assertSubString("<div class=\"test_output_name\">", results);
74: assertSubString(
75: "<a href=\"FullName\" id=\"RelativeName\">RelativeName</a>",
76: results);
77: assertSubString(
78: "<div class=\"alternating_block_1\">starting output</div>",
79: results);
80:
81: assertSubString(
82: "<a href=\"NewFullName\" id=\"NewRelativeName\">NewRelativeName</a>",
83: results);
84: assertSubString(
85: "<div class=\"alternating_block_2\">second test</div>",
86: results);
87: }
88: }
|