##### Coverage Report - org.jbehave.core.configuration.PropertyBasedConfiguration

Classes in this File | Line Coverage | Branch Coverage | Complexity
PropertyBasedConfiguration |
100% | 8/8
100% | 4/4
| 3.0;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 |  |
              * @deprecated Use StoryReporterBuilder()
31 |  |
              */
32 |  |
             public StoryReporter defaultStoryReporter() {
33 | 2 |
                     StoryReporter storyReporter = super.defaultStoryReporter();
34 | 2 |
                     if (System.getProperty(SILENT_SUCCESS) == null) {
35 | 1 |
                             return storyReporter;
36 |  |
                     } else {
37 | 1 |
                             return new SilentSuccessFilter(storyReporter);
38 |  |
                     }
39 |  |
             }
40 |  |
41 |  |
             /**
42 |  |
              * <p>
43 |  |
              * If the system property {@link #FAIL_ON_PENDING} is set, returns
44 |  |
              * {@link FailingUponPendingStep} otherwise returns the default.
45 |  |
              * </p>
46 |  |
              * <p>
47 |  |
              * Setting {@link #FAIL_ON_PENDING} will cause pending steps to fail story
48 |  |
              * execution, so you can see if any steps don't match or are still to be
49 |  |
              * implemented.
50 |  |
              * </p>
51 |  |
              */
52 |  |
             public PendingStepStrategy pendingStepStrategy() {
53 | 2 |
                     if (System.getProperty(FAIL_ON_PENDING) == null) {
54 | 1 |
                             return super.pendingStepStrategy();
55 |  |
                     }
56 | 1 |
                     return new FailingUponPendingStep();
57 |  |
             }
58 |  |
59 |  |
     }