##### Coverage Report - org.jbehave.core.reporters.HtmlOutput

Classes in this File | Line Coverage | Branch Coverage | Complexity
HtmlOutput |
100% | 67/67
N/A | N/A
| 1.0;1

1 |  |
     package org.jbehave.core.reporters;
2 |  |
3 |  |
     import org.jbehave.core.configuration.Keywords;
4 |  |
     import org.jbehave.core.i18n.LocalizedKeywords;
5 |  |
6 |  |
     import java.io.PrintStream;
7 |  |
     import java.util.Properties;
8 |  |
9 |  |
     import static org.jbehave.core.reporters.PrintStreamOutput.Format.HTML;
10 |  |
11 |  |
     /**
12 |  |
      * <p>
13 |  |
      * Story reporter that outputs to a PrintStream, as HTML. It extends
14 |  |
      * {@link PrintStreamOutput}, providing HTML-based default output
15 |  |
      * patterns, which can be overridden via the {@link
16 |  |
      * HtmlOutput (PrintStream,Properties)} constructor.
17 |  |
      * </p>
18 |  |
      *
19 |  |
      * @author Mirko FriedenHagen
20 |  |
      * @author Mauro Talevi
21 |  |
      */
22 |  |
     public class HtmlOutput extends PrintStreamOutput {
23 |  |
24 |  |
         public HtmlOutput(PrintStream output) {
25 | 2 |
             this(output, new Properties());
26 | 2 |
         }
27 |  |
28 |  |
         public HtmlOutput(PrintStream output, Properties outputPatterns) {
29 | 3 |
             this(output, outputPatterns, new LocalizedKeywords());
30 | 3 |
         }
31 |  |
32 |  |
             public HtmlOutput(PrintStream output, Keywords keywords) {
33 | 8 |
                     this(output, new Properties(), keywords);
34 | 8 |
             }
35 |  |
36 |  |
             public HtmlOutput(PrintStream output, Properties outputPatterns, Keywords keywords) {
37 | 11 |
                     this(output, outputPatterns, keywords, false);
38 | 11 |
             }
39 |  |
40 |  |
         public HtmlOutput(PrintStream output, Properties outputPatterns,
41 |  |
                 Keywords keywords, boolean reportFailureTrace) {
42 | 11 |
             this(output, mergeWithDefault(outputPatterns), keywords, reportFailureTrace, false);
43 | 11 |
         }
44 |  |
45 |  |
         public HtmlOutput(PrintStream output, Properties outputPatterns,
46 |  |
                 Keywords keywords, boolean reportFailureTrace, boolean compressFailureTrace) {
47 | 11 |
             super(HTML, output, mergeWithDefault(outputPatterns), keywords, reportFailureTrace, compressFailureTrace);
48 | 11 |
         }
49 |  |
50 |  |
         private static Properties mergeWithDefault(Properties outputPatterns) {
51 | 22 |
             Properties patterns = defaultHtmlPatterns();
52 |  |
             // override any default pattern
53 | 22 |
             patterns.putAll(outputPatterns);
54 | 22 |
             return patterns;
55 |  |
         }
56 |  |
57 |  |
         private static Properties defaultHtmlPatterns() {
58 | 22 |
             Properties patterns = new Properties();
59 | 22 |
             patterns.setProperty("dryRun", "<div class=\"dryRun\">{0}</div>\n");
60 | 22 |
             patterns.setProperty("beforeStory", "<div class=\"story\">\n<h1>{0}</h1>\n<div class=\"path\">{1}</div>\n");
61 | 22 |
             patterns.setProperty("storyCancelled", "<div class=\"cancelled\">{0} ({1} {2} s)</div>\n");
62 | 22 |
             patterns.setProperty("afterStory", "</div>\n");
63 | 22 |
             patterns.setProperty("pendingMethod", "<div><pre class=\"pending\">{0}</pre></div>\n");
64 | 22 |
             patterns.setProperty("metaStart", "<div class=\"meta\">\n<div class=\"keyword\">{0}</div>\n");
65 | 22 |
             patterns.setProperty("metaProperty", "<div class=\"property\">{0}{1} {2}</div>\n");
66 | 22 |
             patterns.setProperty("metaEnd", "</div>\n");
67 | 22 |
             patterns.setProperty("filter", "<div class=\"filter\">{0}</div>\n");
68 | 22 |
             patterns.setProperty("narrative", "<div class=\"narrative\"><h2>{0}</h2>\n<div class=\"element inOrderTo\"><span class=\"keyword inOrderTo\">{1}</span> {2}</div>\n<div class=\"element asA\"><span class=\"keyword asA\">{3}</span> {4}</div>\n<div class=\"element iWantTo\"><span class=\"keyword iWantTo\">{5}</span> {6}</div>\n</div>\n");
69 | 22 |
             patterns.setProperty("beforeScenario", "<div class=\"scenario\">\n<h2>{0} {1}</h2>\n");
70 | 22 |
             patterns.setProperty("afterScenario", "</div>\n");
71 | 22 |
             patterns.setProperty("afterScenarioWithFailure", "<pre class=\"failure\">{0}</pre>\n</div>\n");
72 | 22 |
             patterns.setProperty("givenStories", "<div class=\"givenStories\">{0} {1}</div>\n");
73 | 22 |
             patterns.setProperty("givenStoriesStart", "<div class=\"givenStories\">{0}\n");
74 | 22 |
             patterns.setProperty("givenStory", "<div class=\"givenStory\">{0} {1}</div>\n");
75 | 22 |
             patterns.setProperty("givenStoriesEnd", "</div>\n");
76 | 22 |
             patterns.setProperty("successful", "<div class=\"step successful\">{0}</div>\n");
77 | 22 |
             patterns.setProperty("ignorable", "<div class=\"step ignorable\">{0}</div>\n");
78 | 22 |
             patterns.setProperty("pending", "<div class=\"step pending\">{0} <span class=\"keyword pending\">({1})</span></div>\n");
79 | 22 |
             patterns.setProperty("notPerformed", "<div class=\"step notPerformed\">{0} <span class=\"keyword notPerformed\">({1})</span></div>\n");
80 | 22 |
             patterns.setProperty("failed", "<div class=\"step failed\">{0} <span class=\"keyword failed\">({1})</span><br/><span class=\"message failed\">{2}</span></div>\n");
81 | 22 |
             patterns.setProperty("restarted", "<div class=\"step restarted\">{0} <span class=\"message restarted\">{1}</span></div>\n");
82 | 22 |
             patterns.setProperty("outcomesTableStart", "<div class=\"outcomes\"><table>\n");
83 | 22 |
             patterns.setProperty("outcomesTableHeadStart", "<thead>\n<tr>\n");
84 | 22 |
             patterns.setProperty("outcomesTableHeadCell", "<th>{0}</th>");
85 | 22 |
             patterns.setProperty("outcomesTableHeadEnd", "</tr>\n</thead>\n");
86 | 22 |
             patterns.setProperty("outcomesTableBodyStart", "<tbody>\n");
87 | 22 |
             patterns.setProperty("outcomesTableRowStart", "<tr class=\"{0}\">\n");
88 | 22 |
             patterns.setProperty("outcomesTableCell", "<td>{0}</td>");
89 | 22 |
             patterns.setProperty("outcomesTableRowEnd", "</tr>\n");
90 | 22 |
             patterns.setProperty("outcomesTableBodyEnd", "</tbody>\n");
91 | 22 |
             patterns.setProperty("outcomesTableEnd", "</table></div>\n");
92 | 22 |
             patterns.setProperty("beforeExamples", "<div class=\"examples\">\n<h3>{0}</h3>\n");
93 | 22 |
             patterns.setProperty("examplesStep", "<div class=\"step\">{0}</div>\n");
94 | 22 |
             patterns.setProperty("afterExamples", "</div>\n");
95 | 22 |
             patterns.setProperty("examplesTableStart", "<table>\n");
96 | 22 |
             patterns.setProperty("examplesTableHeadStart", "<thead>\n<tr>\n");
97 | 22 |
             patterns.setProperty("examplesTableHeadCell", "<th>{0}</th>");
98 | 22 |
             patterns.setProperty("examplesTableHeadEnd", "</tr>\n</thead>\n");
99 | 22 |
             patterns.setProperty("examplesTableBodyStart", "<tbody>\n");
100 | 22 |
             patterns.setProperty("examplesTableRowStart", "<tr>\n");
101 | 22 |
             patterns.setProperty("examplesTableCell", "<td>{0}</td>");
102 | 22 |
             patterns.setProperty("examplesTableRowEnd", "</tr>\n");
103 | 22 |
             patterns.setProperty("examplesTableBodyEnd", "</tbody>\n");
104 | 22 |
             patterns.setProperty("examplesTableEnd", "</table>\n");
105 | 22 |
             patterns.setProperty("example", "\n<h3 class=\"example\">{0} {1}</h3>\n");
106 | 22 |
             patterns.setProperty("parameterValueStart", "<span class=\"step parameter\">");
107 | 22 |
             patterns.setProperty("parameterValueEnd", "</span>");
108 | 22 |
             patterns.setProperty("parameterValueNewline", "<br/>");
109 | 22 |
             return patterns;
110 |  |
         }
111 |  |
112 |  |
     }