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