Cucumber and Gherkin: a guide to open-source automation testing

spriteCloud
3 min readAug 10, 2020

--

Quality assurance software testing, and particularly test automation, are our bread and butter here at spriteCloud. Sure, we also provide our clients with cybersecurity penetration testing, manual/functional testing and performance and load testing, but our core area of expertise remains helping clients achieve the benefits of automating their software tests.

To this end, we love open-source tools and we have a particularly strong romance with Cucumber and Gherkin. As testers, we look at the world through the lens of software testing. We often work with clients to help them achieve their business goals through high-quality testing, which involves helping to link testing to development and to business goals. This is at the core of Behaviour Driven Development (BDD), to encourage the collaboration between the business, developers, and tester. We’ll talk about BDD a little more later.

As Cucumber and Gherkin embody many of the principles we hold dear at spriteCloud — quality, collaboration, and open-source (just to mention a few) — we have written a lot about using Cucumber and Gherkin for software testing. This article is, therefore, intended to serve as our main knowledge resource.

Cucumber and Gherkin inextricably linked to Test Automation. Similar to this guide, we’ve put together a Test Automation guide to help collect our knowledge on the topic. Head to our guide, ‘Test Automation: nearly everything you need to know.’

Table of Contents

Cucumber and Gherkin: Important Concepts
- What is Cucumber?
- Behaviour Driven Development (BDD) with Cucumber
- User Story
- Example of User Stories
- What is Gherkin?
- How does Gherkin work?
The Basics of Cucumber and Gherkin
Setup Guides
Testing with Cucumber
- Web Testing with Cucumber
- Mobile Test Automation with Cucumber
Cucumber and Gherkin in the Cloud

Cucumber and Gherkin: Important Concepts

Cucumber and the Gherkin syntax are spriteCloud’s preferred tool and language. This is because they are open-source (making them widely available for diverse teams) and because the Gherkin syntax allows easier readability of test scenarios helping to bridge the gaps between stakeholders. To give more insight into why we love the powerful duo, we will explain a few important concepts.

What is Cucumber?

Cucumber is an open-source, software tool that supports the Behaviour Driven Development (BDD) framework for writing automated acceptance tests. Cucumber is written in the Gherkin language to define test cases, more of which will be explained later on. Cucumber was originally written in Ruby but now supports various other programming languages like Java, JavaScript, Python and .Net. Cucumber is often used along with Selenium and Watir (amongst others). Our setup guide will explain how to to get started with using our preferred setup of Ruby, Cucumber and Watir.

Behaviour Driven Development (BDD) with Cucumber

Behavior Driven Development is an agile software development process that is designed to encourage collaboration between the ‘three amigos,’ i.e. business managers, developers, and testers. BDD was born out of test-driven development and is about rethinking the approach to unit testing and acceptance testing.

According to Wikipedia, the Principles of BDD are:

  • Define a test set for the unit first;
  • Make the tests fail;
  • Then implement the unit;
  • Verify that the implementation of the unit makes the tests succeed.

Domain-specific scripting languages are converted into natural language statements that can express the behaviour and expected outcomes as executable tests. Unit tests should be written in order of business value, with acceptance testing being written using the standard agile framework, i.e. a user story using the classes ‘Given’, ‘When’, and ‘Then’.

Read more about Behavior-Driven Development for Cross-Functional Teams with Cucumber in our article. In the article, we provide an example of a test written without Cucumber and then show how that test should be written using BBD and Cucumber’s Gherkin.

Read the rest of our Cucumber and Gherkin guide on www.spritecloud.com

--

--

spriteCloud
spriteCloud

Written by spriteCloud

We’re spriteCloud, a community of software quality assurance and cybersecurity testers located in Amsterdam. Put quality first!

No responses yet