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

Classes in this File | Line Coverage | Branch Coverage | Complexity
StepFailureDecorator |
67% | 38/56
100% | 2/2
| 1.08;1.08

1 |  |
     package org.jbehave.core.reporters;
2 |  |
3 |  |
     import org.jbehave.core.failures.UUIDExceptionWrapper;
4 |  |
     import org.jbehave.core.failures.StepFailed;
5 |  |
     import org.jbehave.core.model.*;
6 |  |
7 |  |
     import java.util.List;
8 |  |
     import java.util.Map;
9 |  |
10 |  |
     /**
11 |  |
      * <p>
12 |  |
      * When a step fails, the {@link Throwable} that caused the failure is wrapped
13 |  |
      * in a {@link StepFailed} together with the step during which the failure
14 |  |
      * occurred. If such a failure occurs it will throw the {@link StepFailed}
15 |  |
      * after the story is finished.
16 |  |
      * </p>
17 |  |
      *
18 |  |
      * @see StepFailed
19 |  |
      */
20 |  |
     public class StepFailureDecorator implements StoryReporter {
21 |  |
22 |  |
             private final StoryReporter delegate;
23 |  |
             private UUIDExceptionWrapper failure;
24 |  |
25 | 3 |
         public StepFailureDecorator(StoryReporter delegate) {
26 | 3 |
                     this.delegate = delegate;
27 | 3 |
             }
28 |  |
29 |  |
         public void afterScenario() {
30 | 1 |
             delegate.afterScenario();
31 | 1 |
             }
32 |  |
33 |  |
             public void afterStory(boolean givenStory) {
34 | 2 |
                     delegate.afterStory(givenStory);
35 | 2 |
                     if (failure != null) {
36 | 1 |
                             throw failure;
37 |  |
                     }
38 | 1 |
             }
39 |  |
40 |  |
         public void beforeScenario(String scenarioTitle) {
41 | 1 |
             delegate.beforeScenario(scenarioTitle);
42 | 1 |
             }
43 |  |
44 |  |
         public void scenarioMeta(Meta meta) {
45 | 0 |
             delegate.scenarioMeta(meta);
46 | 0 |
         }
47 |  |
48 |  |
         public void beforeStory(Story story, boolean givenStory) {
49 | 1 |
             failure = null;
50 | 1 |
             delegate.beforeStory(story, givenStory);
51 | 1 |
         }
52 |  |
53 |  |
         public void narrative(Narrative narrative) {
54 | 0 |
             delegate.narrative(narrative);
55 | 0 |
         }
56 |  |
57 |  |
         public void failed(String step, Throwable cause) {
58 | 2 |
                     failure = (UUIDExceptionWrapper) cause;
59 | 2 |
                     delegate.failed(step, failure);
60 | 2 |
             }
61 |  |
62 |  |
         public void failedOutcomes(String step, OutcomesTable table) {
63 | 1 |
                     failure = new StepFailed(step, table);
64 | 1 |
                 delegate.failedOutcomes(step, table);
65 | 1 |
         }
66 |  |
67 |  |
         public void beforeStep(String step) {
68 | 0 |
             delegate.beforeStep(step);
69 | 0 |
         }
70 |  |
71 |  |
         public void ignorable(String step) {
72 | 1 |
             delegate.ignorable(step);
73 | 1 |
         }
74 |  |
75 |  |
             public void notPerformed(String step) {
76 | 1 |
                     delegate.notPerformed(step);
77 | 1 |
             }
78 |  |
79 |  |
             public void pending(String step) {
80 | 1 |
                     delegate.pending(step);
81 | 1 |
             }
82 |  |
83 |  |
             public void successful(String step) {
84 | 1 |
                     delegate.successful(step);
85 | 1 |
             }
86 |  |
87 |  |
             public void givenStories(GivenStories givenStories) {
88 | 1 |
                     delegate.givenStories(givenStories);
89 | 1 |
             }
90 |  |
91 |  |
         public void givenStories(List<String> storyPaths) {
92 | 0 |
             delegate.givenStories(storyPaths);
93 | 0 |
         }
94 |  |
95 |  |
         public void beforeExamples(List<String> steps, ExamplesTable table) {
96 | 1 |
                     delegate.beforeExamples(steps, table);
97 | 1 |
             }
98 |  |
99 |  |
             public void example(Map<String, String> tableRow) {
100 | 1 |
                     delegate.example(tableRow);
101 | 1 |
             }
102 |  |
103 |  |
         public void afterExamples() {
104 | 1 |
             delegate.afterExamples();
105 | 1 |
         }
106 |  |
107 |  |
         public void scenarioNotAllowed(Scenario scenario, String filter) {
108 | 0 |
             delegate.scenarioNotAllowed(scenario, filter);
109 | 0 |
         }
110 |  |
111 |  |
         public void storyNotAllowed(Story story, String filter) {
112 | 0 |
             delegate.storyNotAllowed(story, filter);
113 | 0 |
         }
114 |  |
115 |  |
         public void dryRun() {
116 | 1 |
             delegate.dryRun();
117 | 1 |
         }
118 |  |
119 |  |
         public void pendingMethods(List<String> methods) {
120 | 0 |
             delegate.pendingMethods(methods);
121 | 0 |
         }
122 |  |
123 |  |
         public void restarted(String step, Throwable cause) {
124 | 0 |
             delegate.restarted(step, cause);
125 | 0 |
         }
126 |  |
127 |  |
         public void storyCancelled(Story story, StoryDuration storyDuration) {
128 | 0 |
             delegate.storyCancelled(story, storyDuration);
129 | 0 |
         }
130 |  |
     }