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

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

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