JBehave uses annotations and patterns to match steps in textual scenarios to Java methods in the Steps class.

As textual scenarios may be written by non-developers (e.g. BAs or stakeholders), it is important that the scenario writer has the detailed documentation of what language may be used in writing the scenario steps.

The StepdocGenerator generates from an instance of Steps a list of Stepdocs, one for each method annotated with Given, When or Then. The Stepdoc also holds other useful information, such as the aliases that match the same step and the annotated method (e.g. to show the signature).

The generation of Stepdoc is done much in the same way that Scenarios are run. Once instantiated a Scenario, simply invoke the Scenario.generateStepdoc() method. In an IDE, simply extend your Scenario implementation and annotate the generateStepdoc() method with @Test to be able to run it (it is not annotated by default as it is seldomly used):

public class YourScenario extends JUnitScenario {
 
    @Test
    public void generateStepdoc() throws Throwable {
        super.generateStepdoc();
    }
 
}

The StepdocGenerator and StepdocReporter used to perform this task are configurable, via the Configuration class. By default, a simple textual representation is outputted to System.out.

The Stepdoc generation can be equally performed via Ant task and Maven mojo. See the trader example for more details and a working example.

The Scenario Web Runner also supports Stepdoc via a simple page where the use can view the Stepdocs associated to the given Steps instance, with different views (simple and with methods shown).



Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word