How the Gherkin language bridges the gap between customers and developers

The Gherkin syntax helps you think through the process of a transaction with technology and then helps you write it down in a form that translates into programmer logic.
1 reader likes this.
Practicing empathy

Melissa Hogan, CC BY-SA 4.0, via Wikimedia Commons

Communicating with software developers can often be a burdensome task, especially when people lack technical knowledge and technical vocabulary. This is why project managers often use user stories and the versatile system metaphor.

You can assist communication further by utilizing technology designed to facilitate discussions between a project's stakeholders and developers.

The Cucumber framework

Cucumber is an open source framework that enables the creation of automated software tests using an easy-to-write and common language. It's based on the concept of behavior-driven development (BDD), which dictates that creating software should define how a user wants an application to behave when specific conditions are true.

The Cucumber framework isn't "technology" in the modern sense. It's not a collection of bits and bytes. Instead, it's a way of writing in natural language (English, in the case of this article, but so far Gherkin has been translated to over 70 languages). When using the Cucumber framework, you aren't expected to know how to read or write code. You only need to be able to write down ideas you have about how you work. You should also document how you want technology to work for you, using a set of specific terms and guidelines.

What is the Gherkin language?

Cucumber uses Gherkin as a means to define use cases. It's primarily used to generate unambiguous project requirements. In other words, its purpose is to allow users to describe precisely what they require software to do, leaving no room for interpretation or exception. It helps you think through the process of a transaction with technology and then helps you write it down in a form that translates into programmer logic.

Here's an example:

Feature: The Current Account Holder withdraws money
Scenario: The account in question is not lacking in funds
Given that the account balance is £200
And the debit card is valid
And the cash machine contains enough money
When the Current Account Holder requests £50
Then the cash machine dispenses £50
And the account balance is £150
And the debit card is returned

As you can see, this is a highly specific scenario in which an imaginary user requests £50, and the ATM provides £50 and adjusts the user's account balance accordingly. This scenario is just one part of an ATM's purpose, and it only represents a specific component of a person's interaction with a cash machine. When a programmer is given the task to program the machine to respond to a user request, this clearly demonstrates what factors are involved.

What are Gherkin keywords?

The Gherkin syntax makes use of five indispensable statements describing the actions needed to perform a task:

  • Feature: denotes a high-level description of any given software function

  • Scenario: describes a concrete example

  • Given: explains the initial context of the system

  • When: specifies an event or action

  • Then: describes an expected outcome, or a result

  • And (or but): increases text fluidity

By making use of these simple keywords, customers, analysts, testers, and software programmers are empowered to exchange ideas with terminology that's recognizable by all.

Executable requirements and automated testing

Even better, Gherkin requirements are also executable. This is done by mapping each and every keyword to its intended (and clearly stated) functionality. So, to keep with the example above, anything already implemented could automatically be displayed in green:

When the Current Account Holder requests £50*
Then the cash machine dispenses £50*
And the account balance is £150
And the debit card is returned

By extension, Gherkin enables developers to translate requirements into testable code. In practice, you can use specific phrases to check in on your software solutions! If your current code isn't working properly, or a new change has accidentally caused a software error (or two or three) then you can easily pinpoint problems before proceeding to repair them.

Conclusion

Thanks to the Gherkin syntax, your customers will no longer be in a pickle. You can bridge the divide between businesses and developers and deliver outstanding products with greater confidence than ever before.

Find out more about Gherkin by visiting the Cucumber website or its Git repository.

Tags
David Blackwood, Tech Reporter at Software Planet Group
Since achieving my BS in journalism, I have served as a tech evangelist at Software Planet Group, helping not-so-technical business stakeholders to stay on top of IT trends. I am passionate about innovation and technology and write compelling articles on software development and design. Tech Reporter at SPG (https://softwareplanetgroup.co.uk)

Comments are closed.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.