1 | |
package org.jbehave.core.reporters; |
2 | |
|
3 | |
import org.jbehave.core.failures.StepFailed; |
4 | |
import org.jbehave.core.model.ExamplesTable; |
5 | |
import org.jbehave.core.model.Meta; |
6 | |
import org.jbehave.core.model.OutcomesTable; |
7 | |
import org.jbehave.core.model.Scenario; |
8 | |
import org.jbehave.core.model.Story; |
9 | |
|
10 | |
import java.util.List; |
11 | |
import java.util.Map; |
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
public class StepFailureDecorator implements StoryReporter { |
24 | |
|
25 | |
private final StoryReporter delegate; |
26 | |
private StepFailed failure; |
27 | |
|
28 | 3 | public StepFailureDecorator(StoryReporter delegate) { |
29 | 3 | this.delegate = delegate; |
30 | 3 | } |
31 | |
|
32 | |
public void afterScenario() { |
33 | 1 | delegate.afterScenario(); |
34 | 1 | } |
35 | |
|
36 | |
public void afterStory(boolean givenStory) { |
37 | 2 | delegate.afterStory(givenStory); |
38 | 2 | if (failure != null) { |
39 | 1 | throw failure; |
40 | |
} |
41 | 1 | } |
42 | |
|
43 | |
public void beforeScenario(String scenarioTitle) { |
44 | 1 | delegate.beforeScenario(scenarioTitle); |
45 | 1 | } |
46 | |
|
47 | |
public void scenarioMeta(Meta meta) { |
48 | 0 | delegate.scenarioMeta(meta); |
49 | 0 | } |
50 | |
|
51 | |
public void beforeStory(Story story, boolean givenStory) { |
52 | 1 | failure = null; |
53 | 1 | delegate.beforeStory(story, givenStory); |
54 | 1 | } |
55 | |
|
56 | |
public void failed(String step, Throwable cause) { |
57 | 2 | failure = new StepFailed(step, cause); |
58 | 2 | delegate.failed(step, failure); |
59 | 2 | } |
60 | |
|
61 | |
public void failedOutcomes(String step, OutcomesTable table) { |
62 | 1 | failure = new StepFailed(step, table); |
63 | 1 | delegate.failedOutcomes(step, table); |
64 | 1 | } |
65 | |
|
66 | |
public void ignorable(String step) { |
67 | 1 | delegate.ignorable(step); |
68 | 1 | } |
69 | |
|
70 | |
public void notPerformed(String step) { |
71 | 1 | delegate.notPerformed(step); |
72 | 1 | } |
73 | |
|
74 | |
public void pending(String step) { |
75 | 1 | delegate.pending(step); |
76 | 1 | } |
77 | |
|
78 | |
public void successful(String step) { |
79 | 1 | delegate.successful(step); |
80 | 1 | } |
81 | |
|
82 | |
public void givenStories(List<String> storyPaths) { |
83 | 1 | delegate.givenStories(storyPaths); |
84 | 1 | } |
85 | |
|
86 | |
public void beforeExamples(List<String> steps, ExamplesTable table) { |
87 | 1 | delegate.beforeExamples(steps, table); |
88 | 1 | } |
89 | |
|
90 | |
public void example(Map<String, String> tableRow) { |
91 | 1 | delegate.example(tableRow); |
92 | 1 | } |
93 | |
|
94 | |
public void afterExamples() { |
95 | 1 | delegate.afterExamples(); |
96 | 1 | } |
97 | |
|
98 | |
public void dryRun() { |
99 | 1 | delegate.dryRun(); |
100 | 1 | } |
101 | |
|
102 | |
public void scenarioNotAllowed(Scenario scenario, String filter) { |
103 | 0 | delegate.scenarioNotAllowed(scenario, filter); |
104 | 0 | } |
105 | |
|
106 | |
public void storyNotAllowed(Story story, String filter) { |
107 | 0 | delegate.storyNotAllowed(story, filter); |
108 | 0 | } |
109 | |
|
110 | |
} |