Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/bdd/better-gherkin.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,36 @@ Scenario: Subscriber with a paid subscription can access both free and paid arti
```

With a declarative style, each step communicates an idea, but the exact values aren't specified. The details of *how* the user interacts with the system, such as which specific articles are free or paid, and the subscription level of different test users, are specified in the step definitions (the automation code that interacts with the system). The subscription packages could change in the future. The business could change what content is available to subscribers on free and paid plans, without having to change this scenario and other scenarios that use the same step definitions. If another subscription level is added later, it's easy to add a scenario for that. By avoiding terms like “click a button” that suggest implementation, the scenario is more resilient to implementation details of the UI. The intent of the scenario remains the same, even if the implementation changes later. In addition, having too many implementation details in a scenario, makes it harder to understand the intended behaviour it illustrates.

## In-Between Imperative and Declarative

There is a style between these two. It demonstrates the logical flow, without the details of the user interface. The data can be used to automate the test the core implementation, as well as used to either manually or automatically test the user interface.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear reference. What are "these two"? Something in between "Describing behavior" and "Consider a more declarative style" (the page headings). Or something in between declarative and imperative?

If the latter then this should be under a h3, not a h2.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also hope that we don't recommend manual non-exploratory testing 😉 .

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments. The name was not as descriptive and the reasoning was short. What about something that looked like this.
gherkin better - addition.md

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not suggesting manual non-exploratory testing. The data could be used as the starting point for exploratory testing.

In some cases, automating UI tests is deferred to later in the development process. The data could be used as for a manual test of the UI in the interim.

```gherkin
Background:
Given articles are:
| Title | For Subscription |
| Free Article 1 | Free |
| Paid Article 1 | Paid |
* Domain Term - Subscriptions are
| Free |
| Paid |

Scenario: Free subscribers see only the free articles
Given user is logged in
| User Name | Password | Subscription |
| [email protected] | validPassword123 | Free |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are incidental details. Ideally they're kept out of the Gherkin. I wouldn't recommend this to any one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original scenario was bad. I just copied the data from the first one. Too fast and not enough thought.

There should be a separate scenarios for logging on showing responses for user input variations

When articles are displayed
Then articles shown are
| Title |
| Free Article 1 |

Scenario: Subscriber with a paid subscription can access both free and paid articles
Given user is logged in
| User Name | Password | Subscription |
| [email protected] | validPassword123 | Paid |
When articles are displayed
Then articles shown are
| Title |
| Free Article 1 |
| Paid Article 1 |
```