ContextStepMonitor.java

  1. package org.jbehave.core.steps;

  2. import java.lang.reflect.Method;

  3. import org.jbehave.core.context.Context;
  4. import org.jbehave.core.context.ContextView;

  5. /**
  6.  * Decorator of {@link StepMonitor} which shows the current context via the
  7.  * {@link ContextView}.
  8.  */
  9. public class ContextStepMonitor extends DelegatingStepMonitor {

  10.     private final Context context;
  11.     private final ContextView view;

  12.     public ContextStepMonitor(Context context, ContextView view,
  13.             StepMonitor... delegates) {
  14.         super(delegates);
  15.         this.context = context;
  16.         this.view = view;
  17.     }

  18.     @Override
  19.     public void beforePerforming(String step, boolean dryRun, Method method) {
  20.         String currentStory = context.getCurrentStory();
  21.         String currentScenario = context.getCurrentScenario();
  22.         view.show(currentStory, currentScenario, step);
  23.         super.beforePerforming(step, dryRun, method);
  24.     }

  25. }