org.jbehave.scenario
Class AbstractScenario

java.lang.Object
  extended by org.jbehave.scenario.AbstractScenario
All Implemented Interfaces:
RunnableScenario
Direct Known Subclasses:
JUnitScenario.JUnitScenarioDelegate

public abstract class AbstractScenario
extends java.lang.Object
implements RunnableScenario

Abstract implementation of Scenario which is primarily intended as a base class for delegate implementations of Scenarios. As such, it has no explicit supports for any test framework, ie it requires the runScenario method to be invoked directly, and the class of the scenario being run needs to be provided explicitly.

Typically, users will find it easier to extend decorator scenarios, such as JUnitScenario which also provide support for test frameworks and also provide the scenario class as the one being implemented by the user.

Whichever Scenario class one chooses to extends, the steps for running a scenario are the same:

  1. Extend the chosen scenario class and name it after your scenario, eg "ICanLogin.java" (note that there is no obligation to have the name of the class end in "Scenario" although you may choose to).
  2. The scenario class should be in a matching text file in the same place, eg "i_can_login" (this uses the default name resolution, although the it can be configured via the ScenarioNameResolver).
  3. Write some steps in your text scenario, starting each new step with Given, When, Then or And. The keywords can be configured via the KeyWords class, eg they can be translated/localized to other languages.
  4. Then move on to extending the Steps class and providing matching methods for the steps defined in the text scenario.

    1. Constructor Summary
      AbstractScenario(java.lang.Class<? extends RunnableScenario> scenarioClass, CandidateSteps... candidateSteps)
                 
      AbstractScenario(java.lang.Class<? extends RunnableScenario> scenarioClass, Configuration configuration, CandidateSteps... candidateSteps)
                 
      AbstractScenario(java.lang.Class<? extends RunnableScenario> scenarioClass, ScenarioRunner scenarioRunner, CandidateSteps... candidateSteps)
                 
      AbstractScenario(java.lang.Class<? extends RunnableScenario> scenarioClass, ScenarioRunner scenarioRunner, Configuration configuration, CandidateSteps... candidateSteps)
                 
       
      Method Summary
       void addSteps(CandidateSteps... steps)
                 
       void generateStepdoc()
                 
       Configuration getConfiguration()
                 
       java.util.List<CandidateSteps> getSteps()
                 
       void runScenario()
                 
       void useConfiguration(Configuration configuration)
                 
       
      Methods inherited from class java.lang.Object
      clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
       

      Constructor Detail

      AbstractScenario

      public AbstractScenario(java.lang.Class<? extends RunnableScenario> scenarioClass,
                              CandidateSteps... candidateSteps)

      AbstractScenario

      public AbstractScenario(java.lang.Class<? extends RunnableScenario> scenarioClass,
                              Configuration configuration,
                              CandidateSteps... candidateSteps)

      AbstractScenario

      public AbstractScenario(java.lang.Class<? extends RunnableScenario> scenarioClass,
                              ScenarioRunner scenarioRunner,
                              CandidateSteps... candidateSteps)

      AbstractScenario

      public AbstractScenario(java.lang.Class<? extends RunnableScenario> scenarioClass,
                              ScenarioRunner scenarioRunner,
                              Configuration configuration,
                              CandidateSteps... candidateSteps)
      Method Detail

      runScenario

      public void runScenario()
                       throws java.lang.Throwable
      Specified by:
      runScenario in interface RunnableScenario
      Throws:
      java.lang.Throwable

      useConfiguration

      public void useConfiguration(Configuration configuration)
      Specified by:
      useConfiguration in interface RunnableScenario

      getConfiguration

      public Configuration getConfiguration()
      Specified by:
      getConfiguration in interface RunnableScenario

      addSteps

      public void addSteps(CandidateSteps... steps)
      Specified by:
      addSteps in interface RunnableScenario

      getSteps

      public java.util.List<CandidateSteps> getSteps()
      Specified by:
      getSteps in interface RunnableScenario

      generateStepdoc

      public void generateStepdoc()
      Specified by:
      generateStepdoc in interface RunnableScenario


      Copyright © 2003-2010. All Rights Reserved.