Class Scenario<GIVEN,WHEN,THEN>

java.lang.Object
com.tngtech.jgiven.impl.ScenarioBase
com.tngtech.jgiven.impl.Scenario<GIVEN,WHEN,THEN>
Type Parameters:
GIVEN - the Given stage
WHEN - then When stage
THEN - then Then stage

public class Scenario<GIVEN,WHEN,THEN> extends ScenarioBase
A default scenario implementation that takes three type arguments, one for each stage.
  • Constructor Details

  • Method Details

    • getGivenStage

      public GIVEN getGivenStage()
    • getWhenStage

      public WHEN getWhenStage()
    • getThenStage

      public THEN getThenStage()
    • addIntroWord

      public void addIntroWord(String word)
    • create

      public static <GIVEN, WHEN, THEN> Scenario<GIVEN,WHEN,THEN> create(Class<GIVEN> givenClass, Class<WHEN> whenClass, Class<THEN> thenClass)
      Creates a scenario with 3 different steps classes. To share state between the different steps instances use the ScenarioState annotation
      Parameters:
      givenClass - the Given steps class
      whenClass - the When steps class
      thenClass - the Then steps class
      Returns:
      the new scenario
    • create

      public static <STEPS> Scenario<STEPS,STEPS,STEPS> create(Class<STEPS> stepsClass)
      Creates a scenario with a single steps class. Only creates a single steps instance for all three step types, so no ScenarioState annotations are needed to share state between the different steps instances.
      Parameters:
      stepsClass - the class to use for given, when and then steps
      Returns:
      the new scenario
    • startScenario

      public Scenario<GIVEN,WHEN,THEN> startScenario(String description)
      Describes the scenario. Must be called before any step invocation.
      Overrides:
      startScenario in class ScenarioBase
      Parameters:
      description - the description
      Returns:
      this for a fluent interface
    • initialize

      protected void initialize()
      Overrides:
      initialize in class ScenarioBase
    • as

      public Scenario<GIVEN,WHEN,THEN> as(String description)
    • given

      public GIVEN given()
    • when

      public WHEN when()
    • then

      public THEN then()
    • given

      public GIVEN given(String translatedGiven)
    • when

      public WHEN when(String translatedWhen)
    • then

      public THEN then(String translatedThen)