We found it useful to have a cucumber writing standard document where everyone can use it as a reference to write the scenarios. Without the standard we will have inconsistency in the features files.
1. The first cucumber writing standard that we have is to use a third person narrative when we write Given/When steps.
Given the user is on Google homepage
And the user clicks on the Google Search button
We find it more relevant to use "the user" instead of using the first person narrative "I"
2. We use "is/are" in the Given steps for assigning a variable.
Given price is "5" dollar
And quantity is "10"
And we use "should" in the Then steps for asserting result
Then the total price should be "50" dollar
This is so that we can differentiate quickly which one is the pre condition and which one is the assertion.
The above examples are the two things that are most argued in our team. Some people prefer to use "I" and some don't like to use the word 'should'. I guess there is no right or wrong answer. However, since we are working in a team, it is important that we come up with a cucumber writing standard so that we can have a consistent writing.
3. Condition statements (e.g if statements) are to be avoided in the scenario. This might sound obvious but for a tester who is new to cucumber might not find it that obvious.
Instead of
Given the user is on Yahoo.com
Then the user should see his name if the user has signed in
We separate the scenarios into two lines
Scenario: User has signed in
Given the user is on Yahoo.com
When the user signs in into his account as "bananta"
Then the user should see his name as "bananta"
Scenario: User has not signed in
Given the user is on Yahoo.com
Then the user should not see "bananta"
4. Another standard that we have is that testers own/maintain the cucumber scenarios and the developers maintains the steps defintions. In other words, testers should not modify the steps definition and developers should not modify the test scenarios. This might sound obvious but in our case, the devs are modifying the scenarios without the testers' knowledge which cause the test cases to behave
differently.
We have more cucumber writing standards that are specific to our projects but the above examples are the main one that we have.