Gherkin For QA— A primer to write scenarios

Veera.
2 min readMar 25, 2022

Of late, the adaption of creating and maintaining testing scenarios in Gherkin is gaining popularity in software testing community, not only in the purview of test automation, but also in manual testing space. It’s in fact a best thing to do if test scenarios (or test cases) are being maintained in the same format and have a direct traceability between automated scenarios against the manual test suite. In addition, this practice also prevents the risks of missing out critical validation steps while translating conventional test scenarios(or test cases) to Gherkin formatted scenarios during automation.

In this blog, my idea is to share my thoughts, that can help beginners to write scenarios eloquently, yet simple in Gherkin format, essentially capturing all details and nuances in achieving overall test coverage optimally.

Every scenario in a feature has an intent or a purpose and generally, it’s that a value that customers expect a product to offer. And for customers, they are to follow a step or a sequence of steps before they reach a point that leads to achieve their intent.

Let’s illustrate it with a simple example using Google currency calculator. Suppose I have a $100 bill with him, and want to calculate its current worth in INR. Now, finding a current value of $100 in INR is my intent, and so is our scenario’s intent. If I were to elaborate this scenario, containing multiple steps using Gherkin language, it would be more or less similar to what’s written in the following lines.

Scenario : To calculate the value of $100 in INR equivalent using Google Calculator

Given I visit Google to calculate value of $100 in INR.

When I update value as $100 in USD equivalent

Then I should confirm INR equivalent gets updated as 7625.39

In essence, all preconditions to the scenario are generally captured using the keyword Given, things or actions that are required to be done before we reach our intent are to be captured via When and finally, the actual intents are to be asserted through the keyword: Then.

To summarise, Given, When & Then are building blocks of Gherkin language and each of them must be used at-least once in a scenario so it is coherent and complete.

Thank you for reading!

--

--

Veera.

I'm a Software QE professional with over 14 years of industry experience; https://www.linkedin.com/in/5v1988