BDD encourages the description of the acceptance tests in a manner that is intelligible and transparent to the business users. This in particular may mean setting up explicitly via scenario steps all the pre-requirements of a particular scenario. For complex scenarios this will rapidly lead to maintainance problems due to duplication of entire blocks of steps.
To help the user better manager more complex scenarios, JBehave allow the specification of entire scenarios as a pre-requisite for another scenario.
Scenario: A scenario in which the user can run other scenarios as pre-requisites GivenScenarios: path/to/scenario1,path/to/scenario2,...path/to/scenarioN Given ... // normal scenario steps
When JBehave encounters the keyword GivenScenarios, it will run the (one or more) textual scenarios specifed by path in the list (using the same Steps instances specified for the parent scenario) before proceeding to the execution of the normal scenario steps.
Another way to avoid duplication of textual scenario steps is to use the natural ordering of execution of the scenario classes. Typically, this means that the scenarios will be executed in the alphabetical order of their names and a convention can be adopted to have scenarios start with an alphanumberical prefix, such as 'Snn' where 'nn' is an incremental number. This though has the disadvantage of having to run all scenarios leading up to the desired scenario, which in some cases can be unnecessary and time consuming. For example, for debugging purposes one may need to one run one scenario, which may have a dependency on just one other. This is where GivenScenarios is most useful.