gauge-logo

Behaviour Driven Testing using Gauge, and how it can accelerate your speed to market

Gauge is a tool created by ThoughtWorks .Inc – pioneers of Selenium. It is a type of Behaviour Driven Testing process which enables innovators to accelerate their products and services onto the market. It is an efficient, lightweight, open source, cross-platform tool, with a built-in CLI, which we have been using successfully for sometime at Mitra Innovation.

Mitra Innovation likes to share knowledge and experience, and so we thought it would be helpful to not only explain what Gauge is, but also to show how it can be used (with a step-by-step guide), and how it can help accelerate the development of your own products and services.

Behaviour Driven Testing – The Background

Behaviour Driven Testing (BDT) is a lesser known companion of Behaviour Driven Development (BDD) – a software development process which combines the general techniques and principles of Test Driven Development (TDD), with domain-driven design and object-oriented analysis and design. The goal of BDT is a business readable and domain specific language that allows for a description of a system’s behaviour without detailing how that behaviour is implemented.

BDT benefits:

● BDT focuses on the business point of view and requirements of software rather than the technical implementation
● BDT encourages collaboration between developers, QA, and business participants, in an effort to help bridge the business/IT gap.

BDT has gained momentum as many organisations use it as a solution for automation and collaboration challenges. The BDT framework has been successfully implemented by various QA teams in various domains.

Behaviour Driven Testing and Gauge

Gauge is a particular type of open source Behaviour Driven Testing tool.The successful concept behind it is ‘Living and Executable Documentation’, i.e. a document that can be continually edited and updated.

Gauge benefits:


● The documents/specifications are all written in Business Language – Markdown format
● It is useful and applicable to Agile based environments because stakeholders can review documentation to ensure that specifications describe the expected behaviour of the system from an end-user point of view
● It can include a complete set of specifications, with checks for correctness on each implementation.


Gauge also has a number of other useful features and benefits:


● Stakeholders can understand tests in text rather than in syntax
● It is open source and provides cross platform / languages support for writing test code
● It supports Data Driven Tests and helps to create maintainable test suites
● The automatic report generation and the ability to generate test specification documentation is very useful when it comes to test reporting and getting the sign off for the test cases from the customer
● HTML document generation
● Parallel test execution support which saves time
● Data Store Support – to share data in steps defined in different classes at runtime
● Tagged test execution which allows the running of specific tests providing tag(s) name in specs or scenarios separately (without running the entire tests), which is handy when running a regression test on a specific module after a bug fix.

Gauge can be used without a large amount of familiarisation and can be installed and initialised with a command. Additionally, it is not restricted to any certain Integrated Development Environment (IDE) or to a platform.

Here is an outline of a BDT process using the Gauge framework:
1. The Business Analyst identifies features the customer wants as User Stories
2. QA personnel pick User Stories and identify test scenarios
3. QA personnel writes Test Steps in behaviour driven Test Specifications using Gauge
4. QA personnel implements the underlying code.
5. Code is deployed and automated test cases get executed
6. Bugs get fixed, and set of automated tests run as regression tests
7. When complete, the customer accepts the software.

Gauge tests can be implemented in C#, Java, JavaScript, Python and Ruby as standard and are supported by IDEs such as IntelliJ, Eclipse and Visual Studio.

Gauge can also be integrated into the build tools Maven and Gradle and includes the two report plugins HTML report and XML report. Large quantities of test data can be read from text files, CSV and additional formats keeping the specifications readable.

Getting started with Gauge – Step-By-Step Guide and a Few Handy Hints and Tips

In order to understand (a) how BDT works using the Gauge tool, (b) the use of Gauge as an open source framework, and (c) how Gauge fits into an Agile environment, we’ve outlined an example below that you could follow as a developer.

The example also demonstrates the differences between traditional automation and BDT using Gauge.

Let’s begin

The following example begins with a Login Screen.

First, you’ll need to identify Test Scenarios, then identify Test Cases and Test Steps. Depending on the Application Under Test (AUT), the number of scenarios may vary based on types of user roles, privileges etc.

The image below shows a specification (Login.spec) with three scenarios. It begins with the specification name and then scenario names.

bdt-step-1a

Step 1: Load the login page

The steps are written as bullet points. For example, the steps for the first scenario ‘Registered user login to the system’:

The image below provides an overview of the solution we developed:

The steps are written as bullet points. For example, the steps for the first scenario ‘Registered user login to the system’:

* Login as “user_name” using “password”

* The user is successfully logged in

Every step has an underlying code implementation which is executed when the steps inside a spec are executed. The implementation of the tests can be in any language supported by Gauge. Gauge currently supports Intellij, IDEA, and Visual Studio which means plugins can be installed by downloading them from their respective plugin repositories. These plugins would ease the work from project creation, to step implementation, to auto completion, and many more.

Step 2: Create a /resources/users.csv file including user_name and password

bdt-step-2

Step 3: Create a data driven test using the users.csv

login-spec

Step 4: The image below represents the step implementation in python, for the login page

step 4

Step 5: The Login Page Factory in python looks like this

step 5

Step 6: Now the test can be run specifying the spec name as per the image below

Step 6

Step 7: Gauge will automatically generate a HTML report

Step 7

Step 8: The additional Gauge add-on, Spectacle, can be used to generate a HTML Document

Step 8
Step 9

Improving delivery speed with BDT using Gauge

When it comes to the behaviour of software, end users are generally not concerned about the technical implementation. Therefore, when it comes to testing, the focus should be on testing the system level behaviour rather than thinking about the testing code.

Gauge’s focus on executable documentation, working closely with the Business Analysts and reviewing the generated Specification Documents help to improve delivery speed for each project. This, in turn, helps QA personnel to deliver tests quicker; as stories will be covered as functional tests.

The QA team write tests that are just enough to cover the intended behaviour of the system ensuring good test coverage. All tests are equally important and it is a priority to run tests at the same time. Even without a working system the design, the specification, and the underlying tests can be carried out.

With Gauge, the Return on Investment (ROI) is higher due to the focus on ‘Business Value’ rather than ‘Abstract Ideas’.

Finally, BDT using Gauge allows for greater customer satisfaction because ‘Customer Use’ is emphasised more than ‘Technical Implementation’.

We recommend Gauge

Mitra Innovation recommends Gauge to any test automation engineer, especially as it’s simple and straightforward to get started. Furthermore, Gauge provides a variety of helpful functions which include:

Context steps and teardown steps
Specifications and scenarios with tags
Inputting data from text files and CSV files
Parameter transfer to implementation functions from tables.

In the context of behaviour-driven development, Gauge is a test framework worth considering because of its ability to simplify the test automation tasks of the Application Under Test (AUT) and later execute them as automatic tests maximising ROI.

Finally, combining Agile testing practices with modern automated testing tools such as Gauge enable faster testing without compromising quality, which results in faster delivery.

profile-gem

About the Author

Gemunu Priyadarshana is a QA Lead at Mitra Innovation, a technology company that specialises in product, platform and SaaS incubation services, Cloud-to-Cloud systems integration, and digital innovation and transformation.

Find out how Gemunu and the rest of the Mitra Innovation team can help you make the most out of Behaviour Driven Testing with Gauge.