Question

When writing scenarios, does anyone have a strong argument for choosing one of the following styles over another?

Feature: Search Product

As a customer
I want to search for a product
So that I can easily locate what I want to purchase

Scenario: Multiple Products Found (First Person Style)
Given the following products exist:
|Product      |
|Normal Orange|
|Large Orange |
When I search for "orange" <---
Then the system should display the following products:
|Product      |
|Normal Orange|
|Large Orange |

Or...

Scenario: Multiple Products Found (Generic Third Person Style)
Given the following products exist:
|Product      |
|Normal Orange|
|Large Orange |
When the customer searches for "orange" <---
Then the system should display the following products:
|Product      |
|Normal Orange|
|Large Orange |

Or...

Scenario: Multiple Products Found (Specific Person Style)
Given the following products exist:
|Product      |
|Normal Orange|
|Large Orange |
When "John" searches for "orange" <---
Then the system should display the following products:
|Product      |
|Normal Orange|
|Large Orange |

They all seem to work just fine - I wonder if I'm missing an obvious pitfall, as so many examples seem to use specific values for the actors (not just specific values for inputs / outcomes).

My only argument against using:

When the customer searches for "orange"

is that separate, equivalent steps would have to be defined if other actors could also use the same function.

Personally, I think "I" reads quite well (though I feel like I know otherwise). Thoughts?

Was it helpful?

Solution

It's fine either way, but there is a subtle difference.

I sometimes like to phrase things in the first person if the benefit of the outcome is for the user, and the third person if it's for someone other than the user.

For instance, you might have a story:

In order to prevent bots from spamming the site
As a moderator
I want users to prove that they are human.

And the associated scenario could either read:

Given a user is not registered
When they try to register
Then they should be presented with a CAPTCHA
When they fill in the CAPTCHA
Then they should be successfully registered

Or:

Given I am not registered
When I try to register
Then I should be presented... what, wait, no, I shouldn't!

In this instance, it's obvious that there's a cognitive disconnect with the idea that "I should be presented with a CAPTCHA", since they're annoying and nobody wants them. Putting this scenario in the third person makes it apparent that the benefit may not be for that person.

I occasionally make up names for the users - Ursula Usual for a normal user and Andy Admin for an admin, for instance. Using the third person this way can also be useful for calling out different personas and roles.

There are other scenarios in which the role is the same, but two different people play it.

Given Doctor Donald has filled out Priscilla Patient's prescriptions
When Doctor Diana looks for her file // <-- different doctor!
Then she should be able to find those prescriptions.

In the case in which other actors can use the same function, the context of their roles or permissions will be changing the behavior, and that context should be included in the scenario anyway, even if it's just implicit in their names.

OTHER TIPS

I think as long as the story is clear to developers and non-developers like, I think I is fine to use. At the top you've already clarified that I am a customer. I don't think we care about which particular customer is doing the search.

I think it basically depends on the scenario.

If the scenario is one that will only ever involve customers, then "customer" is probably the most appropriate.

If a scenario may involve classes of users other than customers then the use of "John" (or "Jane", if you prefer) is more generic, and reduces the focus on just one class of user.

In general, systems are being built for somebody else to use, so while I agree that the first person ("I") style reads well, there are probably good psychological reasons for not using it.

Of course, I could be completely confused - I'm fairly new to BDD.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top