Coverage Report - org.jbehave.core.configuration.PropertyBasedConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
PropertyBasedConfiguration
100%
8/8
100%
4/4
3
 
 1  
 package org.jbehave.core.configuration;
 2  
 
 3  
 import org.jbehave.core.failures.FailingUponPendingStep;
 4  
 import org.jbehave.core.failures.PendingStepStrategy;
 5  
 import org.jbehave.core.reporters.SilentSuccessFilter;
 6  
 import org.jbehave.core.reporters.StoryReporter;
 7  
 
 8  
 /**
 9  
  * PropertyBasedConfiguration is backed by MostUsefulConfiguration as default,
 10  
  * but has different behaviour if certain system properties are set:
 11  
  * <ul>
 12  
  * <li>{@link #FAIL_ON_PENDING}: uses {@link FailingUponPendingStep}</li>
 13  
  * <li>{@link #SILENT_SUCCESS}: uses {@link SilentSuccessFilter} decorator</li>
 14  
  * </ul>
 15  
  */
 16  4
 public class PropertyBasedConfiguration extends MostUsefulConfiguration {
 17  
 
 18  
         public static final String FAIL_ON_PENDING = "org.jbehave.core.configuration.failonpending";
 19  
         public static final String SILENT_SUCCESS = "org.jbehave.core.configuration.silentsuccess";
 20  
 
 21  
         /**
 22  
          * <p>
 23  
          * If the system property {@link #SILENT_SUCCESS} is set, uses a
 24  
          * {@link SilentSuccessFilter} to decorate the default StoryReporter.
 25  
          * </p>
 26  
          * <p>
 27  
          * Setting {@link #SILENT_SUCCESS} will only show the steps for all stories
 28  
          * if the stories fail.
 29  
          * </p>
 30  
          */
 31  
         public StoryReporter defaultStoryReporter() {
 32  2
                 StoryReporter storyReporter = super.defaultStoryReporter();
 33  2
                 if (System.getProperty(SILENT_SUCCESS) == null) {
 34  1
                         return storyReporter;
 35  
                 } else {
 36  1
                         return new SilentSuccessFilter(storyReporter);
 37  
                 }
 38  
         }
 39  
 
 40  
         /**
 41  
          * <p>
 42  
          * If the system property {@link #FAIL_ON_PENDING} is set, returns
 43  
          * {@link FailingUponPendingStep} otherwise returns the default.
 44  
          * </p>
 45  
          * <p>
 46  
          * Setting {@link #FAIL_ON_PENDING} will cause pending steps to fail story
 47  
          * execution, so you can see if any steps don't match or are still to be
 48  
          * implemented.
 49  
          * </p>
 50  
          */
 51  
         public PendingStepStrategy pendingStepStrategy() {
 52  2
                 if (System.getProperty(FAIL_ON_PENDING) == null) {
 53  1
                         return super.pendingStepStrategy();
 54  
                 }
 55  1
                 return new FailingUponPendingStep();
 56  
         }
 57  
 
 58  
 }