agile-requirements-framework

Organizing and Managing BDD Scenarios As Your Detailed Requirements

This article provides recommendations on organizing and managing your BDD scenarios so they can serve as the detailed requirements. It provides additional details to support the main article about my proposed requirements framework. The fundamental idea in the proposed framework is to capture the requirements details in your BDD scenarios. To do this each use case is followed by a ‘Detailed Requirement Statements’ sub-section that lists detailed requirements statement. These statements come from the BDD scenarios. This is the secret to how we capture all the details but keep the requirements document minimal.

There are two main points:

Investing in Your Scenarios

The biggest thing needed to make the proposed use of BDD Scenarios as detailed requirements work, is continuous investment in those scenarios. You must:

Beyond requirements presentation, you need to do the above as part of making your agile way-of-working succeed. If you don’t, you’ll start to slow down due to poor understanding of the requirements and struggle to determine why tests fail.

The next biggest thing you need to do is decide how you’ll capture the requirements statements in the scenarios. The Given-When-Then structure of BDD Scenarios is designed to express detailed examples. You must find a way to also write a requirements statement that is at a level above the details of the example. It’s critical for my proposed requirements framework that this statement of requirements be written in a structured way so that tools can process it, e.g., find and extract it for insertion into a comprehensive requirements presentation. Exactly how best to do this depends on the specific tool used for writing and executing the scenarios. Possible approaches include:

Example With Comment


Example With Rule


Example With Feature



Keeping Scenarios Alive

Writing, editing, refactoring these scenarios is the job of the entire team in an on-going cycle:

You need to pick an approach to capturing the requirements details in the scenarios that the team buys into so this cycle is successful.

Technical Approaches

The tool used to define and execute your BDD Scenarios tends to dominate which of the above approaches to capturing the requirements details you choose. The major options are:

The following sub-sections discuss each of these options in the context of my proposed requirements framework.

Using the Cucumber Family

The following shows a use case from a real product4. Don’t focus on the details, instead just note how it follows the proposed standard use case structure of a base flow with alternatives as well as having steps that can include links to other use cases and data.

Example Use Case


The following shows and example of the BDD scenarios that act as detailed requirements statements for the above use case. Don’t focus on the details, instead note that:

Example Use Case

This is an example of using just the scenario description and it’s Given-When-Then text as the detailed requirements. It works and is relatively easy to setup and manage but it tends to result in long lists of detailed requirements because there can be a lot of text in the Given-When-Thens. This problem is why it’s desirable to put an overall requirements statement above the Given-When-Then and only show that overall statement in the requirements presentation.

The presentation is straightforward because the use cases are in a markdown text file and the scenarios are just well structured text files. The specifics of the approach to reporting on this example project were:

I don’t recommend doing a lot of work to organize the list of these requirements statements. I haven’t even tried to break them out by alternative flows. Instead I have just one list per use case. This is an example of an effort vs. benefit vs. risk trade-off. The BDD scenarios should be evolving even more than the use cases and trying to keep them highly organized has proven unsustainable. Instead, the place to invest is the requirements statements in the BDD scenario. It’s worth a lot of investment to make them readable and to fit into the context of the use case they are under.

Using A Commercial Cucumber Family Approach

Because of my desire to have everything in git as text files and have complete control over the presentation of the requirements, I have actively avoided using commercial products supporting Cucumber or other BDD approaches. I expect they do something similar to what the framework does but in a more elaborate and proprietary way. If the tool selected by your team is open enough you can potentially get to results similar to my proposed requirements framework.

Using A Custom BDD Approach

I struggle with the restrictions of Gherkin syntax and standard BDD reports. Gherkin is a Domain Specific Language (DSL) for expressing and executing BDD Acceptance test scenarios. On my most recent project we created a custom DSL for our BDD scenarios. In the first example below the key point for the requirements framework is that the DSL has a requirements statement separate from the definition of the scenario.

gwt

In the second example there is both a requirements statement and a description. The statements and descriptions from these scenarios are what is included under the use cases. This enables a much better presentation of the comprehensive requirements.

timeline

Teams Need Freedom to Pick or Build Their Tools

I see mandates for every team to use the same process and tools in most enterprises. I think this is a mistake. I believe that every project is different enough that the team should be allowed to select and create, as needed, the tools to support their agile way-of-working. Assuming the are using the use case based requirements framework proposed in this article and an existing BDD tool, this should simply mean implementing some scripts to generate the combined use case and BDD scenario presentations. Alternatively they could build a full DSL for expressing, executing, and generating the presentations of their scenarios. To emphasize the point that the team needs to select and build their own tools, I end by saying that the power that comes from building a DSL that enable users to directly and optimally express their scenarios is unlike anything I’ve seen using the existing Cucumber-family tools.

Requirements to Test Traceability

To see coverage of features, traceability from requirements to tests is desirable in every product. It’s mandated in many regulated environments such as the Life Science domain. It’s frequently a painful process where things like a traceability matrix is created that maps requirements numbers to test IDs. Don’t fall into the trap of using the stories in the work management system to build the traceability because user stories are not requirements so the traceability will be technically correct but a conceptual mess. Traceability comes for free in the proposed framework because the tests are part of the requirements. If needed to align with existing SDLC or SOP demands, a simple program, similar to the one that creates the combined presentation of the use cases and the scenarios, can publish the traceability as a matrix in a spreadsheet.

  1. Depending on the technical approach selected the ‘presentation’ of the integrated requirements can take a variety of forms, e.g., a generated markdown, html, pdf, MS-Word document or some combination of these forms. I’ll just say ‘presentation’ to avoid dealing with these details until the technical section. 

  2. The examples are taken from the [^Gherkin-Rules]:(https://cucumber.io/blog/bdd/gherkin-rules/) blog. 

  3. I’m only listing Polarion because it was used on my last project. I avoid these kinds of products so I don’t have current knowledge of others. If they don’t break the user-stories-are-not-requirements rule then they probably work similar to 

  4. The product is INTIENT Clinical