Why I chose Gauge over Cucumber …

Thivya lakshmi
Mar 7, 2018 · 5 min read

I have worked with a popular Behaviour Driven development(BDD) tool, Cucumber in my past projects and was pulled off by its structured gherkin syntax until I started exploring Gauge. This post gives you a quick glimpse about the different features and capabilities Gauge gives when compared with other BDD tools. As cucumber is one of the popular BDD tool,I have compared and contrasted Gauge with cucumber in different aspects on BDD grounds.

To start with, Gauge is an open source BDD tool developed by Thoughtworks. It is one of the open source contributions done in test automation followed by Selenium and Twist by Thoughtworks.

Project Setup Made Easy — How ?

If you are the person who feels, setting up initial project, adding a build tool, specifying dependencies etc,.. is a time consuming and tiring task, then Gauge can help you.

Gauge has considerably reduced automation framework setup time by giving us “Gauge templates”. It has built-in provision of common tasks like reporting, logging, environment specific property files etc.

Through Gauge Templates, Gauge gives us an initial setup of a project with build dependency tool, web driver and language of our choice, as a zip. This greatly saves time invested in setting up project and we can start writing our specifications right away. Bootstrap your java selenium Gauge project in just one line as below,..

Selenium java project setup in a command

Writing tests made simple..

The first difference which comes to my mind is the Markdown syntax of Gauge over Gherkin syntax of cucumber. This gives you the liberty to write tests in an unstructured way than Given/When/Then format of Cucumber.This could be as good as writing a functional document which in turn serves as a test cases documentation.

Specification syntax of Gauge

If you feel that Cucumber is a pain when used in large projects due to its Given-When-Then syntax becoming messy in long run.Gauge can take out that pain to some extent.Even here, the flexibility of free text can be a demerit as they don’t have a defined format.But tests may end up looking like a messy text document unless imposed strict restrictions.

All BDD Concepts still intact ..

Feature wise, the BDD concepts of hooks, background, tags — all of this do exist in Gauge with different terminologies like Context steps, execution hooks, tear down etc, as mentioned here.

Data Stores — Reducing runtime objects maintenance overhead ..

A WOW factor which makes Gauge unique is the “Data stores” concept.

Datastores at scenario level

It is a concept by which (global) data can be passed to different steps in different classes at runtime. The data store can be maintained at scenario level, spec level or suite level, thus eliminating the pain for users, in maintaining runtime variables.

Passing Parameters to steps ..

With Gauge, passing test data to framework doesn’t change much when compared to cucumber, but Gauge has an additional ability to pass large data files to the tests without any effort of writing the parsing logic. Gauge supports passing data as “files” and “tables” to the test step. This makes it easy to pass the most common test data files like Excel and CSV and word.

Passing file names directly to specification

In-house Reporting Capability ..

When it comes to reporting ,Gauge reports are easy and quick to understand. Very comprehensive when compared to Cucumber java HTML reports.

No additional setup code is required for reporting when using Gauge.

Default Gauge HTML reports

By default, html-report is generated after Gauge execution. Gauge has in-built capability of capturing screenshots on failure. It also has flash reporting plugin which can be plugged to CI/CD pipeline to view the real time execution.

Execution support …

Gauge supports various conventional test execution methods like execution at spec level,scenario level,directory level and few others, as mentioned here. Gauge also provides ability to run failed test alone.Gauge also allows data driven and tagged execution same like cucumber.No much difference.

Parallel execution ..

When comes to execution,Gauge has parallel execution by default.Thus eliminating the effort spent in making the test automation framework capable of parallel execution. You can just mark the in-parallel flag as true ,Gauge will take care of running the tests parallely by creating execution threads depending on number of CPU cores available on the machine.

Gauge also gives the provision to execute failed tests alone.

Environments ..

Unlike other tools, Gauge gives us the ease to pass the environment variables without writing related code.We just have to put the environment files in the Gauge defined project structure as mentioned here.

For example, to specify CI properties, create a property file in the format shown in image and specify the properties in it. Gauge will take care of passing the properties to test files.

Default.properties is loaded when no environment is specified.

File structure for property files

Configurations ..

Gauge also allows us to configure the Gauge specific properties and few other java properties using a file Gauge.properties. One thing which I found interesting is with Gauge, you can specify the level at which you want the state of your objects to be cleared — suite, spec, scenario. You can leverage these if you are building your own custom reports with additional capabilities.

Community support ..

Gauge has detailed and well explained documentation with examples and code snippets. They are very active in gitter and they mostly turnaround with replies in one or two days.

They have demo projects with Gauge for beginners to refer and create frameworks.

Like other BDD tools,Gauge also has plugins, runners and IDE support.Not a big difference.

Thus, …

Above are the key factors which I can majorly see, when comparing Gauge to Cucumber and other BDD tools. All of these can be achieved in one or the other way by adding custom plugins and libraries to the framework when using other tools. But Gauge gives us in house capabilities of most of these, thus eliminating the time spent in writing code to make our framework capable of them.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade