How to document non-functional requirements (NFRs) in a story/feature?

Chris Snow picture Chris Snow · Oct 11, 2013 · Viewed 7.4k times · Source

The Specification By Example book states the non-functional requirements (commonly referred to as NFRs) can be specified using examples.

I've also been told by a colleague that non-functional requirements may be specified using SBE stories using the format:

Scenario: ...
   Given ...
   When ...
   Then ...

Here is an example functional and non-functional requirement taken from wikipedia:

A system may be required to present the user with a display of the number of records in a database. This is a functional requirement. How up-to-date this number needs to be is a non-functional requirement. If the number needs to be updated in real time, the system architects must ensure that the system is capable of updating the displayed record count within an acceptably short interval of the number of records changing.

Question 1: Can the non-functional requirement be specified as a story?

Question 2: Should the non-functional requirement be specified as a story?

Question 3: What would the story look like?

Answer

Ben Smith picture Ben Smith · Oct 12, 2013

I'll give an answer by working through an example.

Let us say that your team has already implemented the following story:

Scenario: User can log in to the website
   Given I have entered my login credentials
   When I submit these credentials
   Then I get navigated to my home screen

To answer Question 1) - Can the non-functional requirement be specified as a story?

The project stakeholders have given you a NFR which reads:

For all website actions, a user should wait no longer that five seconds for a response.

You could create a story for this as follows:

Scenario: User can log in to the website in a timely fashion
   Given I have entered my login credentials
   When I submit these credentials
   Then I get navigated to my home screen
   And I should have to wait no longer than the maximum acceptable wait time

Note that instead of imperatively specifying '5' seconds, I have kept the scenario declarative and instead specified "wait no longer than the maximum acceptable wait time".

To answer question 2) - Should the non-functional requirement be specified as a story?

The NFRs should definitely be specified as a story.

Creating a story will allow this task's complexity to be estimated (so that the team can determine how difficult it is relative to past stories), plus the team can break the story down into tasks (which can be estimated in hours, so that you can work out if the team can implement this story in the current sprint).

Hence in my contrived example, the team would have already implemented the code to log-in, but they'd then determine how to implement the requirement that it must take no longer than 5 seconds to log in. You will also allow be able to explore the inverse of this problem i.e. what happens if it takes longer than five seconds to log-in? e.g.

Scenario: User encounters a delay when logging in to the website
       Given I have entered my login credentials
       When I submit these credentials
       And I wait for over the the maximum acceptable wait time
       Then the Production team is informed
       And the problem is logged
       And I get navigated to my home screen

And finally, regarding question 3) - What would the story look like?

I've detailed how the stories would look like in answers 1) and 2)