Coverage Report - org.jbehave.core.reporters.StepFailureDecorator
 
Classes in this File Line Coverage Branch Coverage Complexity
StepFailureDecorator
82%
38/46
100%
2/2
1.1
 
 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.GivenStories;
 6  
 import org.jbehave.core.model.Meta;
 7  
 import org.jbehave.core.model.OutcomesTable;
 8  
 import org.jbehave.core.model.Scenario;
 9  
 import org.jbehave.core.model.Story;
 10  
 
 11  
 import java.util.List;
 12  
 import java.util.Map;
 13  
 
 14  
 /**
 15  
  * <p>
 16  
  * When a step fails, the {@link Throwable} that caused the failure is wrapped
 17  
  * in a {@link StepFailed} together with the step during which the failure
 18  
  * occurred. If such a failure occurs it will throw the {@link StepFailed}
 19  
  * after the story is finished.
 20  
  * </p>
 21  
  * 
 22  
  * @see StepFailed
 23  
  */
 24  
 public class StepFailureDecorator implements StoryReporter {
 25  
 
 26  
         private final StoryReporter delegate;
 27  
         private StepFailed failure;
 28  
 
 29  3
     public StepFailureDecorator(StoryReporter delegate) {
 30  3
                 this.delegate = delegate;
 31  3
         }
 32  
 
 33  
     public void afterScenario() {
 34  1
                 delegate.afterScenario();
 35  1
         }
 36  
 
 37  
         public void afterStory(boolean givenStory) {
 38  2
                 delegate.afterStory(givenStory);
 39  2
                 if (failure != null) {
 40  1
                         throw failure;
 41  
                 }
 42  1
         }
 43  
 
 44  
     public void beforeScenario(String scenarioTitle) {
 45  1
                 delegate.beforeScenario(scenarioTitle);
 46  1
         }
 47  
 
 48  
     public void scenarioMeta(Meta meta) {
 49  0
         delegate.scenarioMeta(meta);
 50  0
     }
 51  
 
 52  
     public void beforeStory(Story story, boolean givenStory) {
 53  1
         failure = null;
 54  1
         delegate.beforeStory(story, givenStory);
 55  1
     }
 56  
 
 57  
         public void failed(String step, Throwable cause) {
 58  2
                 failure = new StepFailed(step, 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 ignorable(String step) {
 68  1
         delegate.ignorable(step);
 69  1
     }
 70  
     
 71  
         public void notPerformed(String step) {
 72  1
                 delegate.notPerformed(step);
 73  1
         }
 74  
 
 75  
         public void pending(String step) {
 76  1
                 delegate.pending(step);
 77  1
         }
 78  
 
 79  
         public void successful(String step) {
 80  1
                 delegate.successful(step);
 81  1
         }
 82  
 
 83  
         public void givenStories(GivenStories givenStories) {
 84  1
                 delegate.givenStories(givenStories);
 85  1
         }
 86  
 
 87  
     public void givenStories(List<String> storyPaths) {
 88  0
         delegate.givenStories(storyPaths);
 89  0
     }
 90  
 
 91  
     public void beforeExamples(List<String> steps, ExamplesTable table) {
 92  1
                 delegate.beforeExamples(steps, table);
 93  1
         }
 94  
 
 95  
         public void example(Map<String, String> tableRow) {
 96  1
                 delegate.example(tableRow);
 97  1
         }
 98  
 
 99  
     public void afterExamples() {
 100  1
         delegate.afterExamples();        
 101  1
     }
 102  
 
 103  
         public void dryRun() {
 104  1
                 delegate.dryRun();
 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  
 }