Gauge is an open source test automation framework which is developed by ThoughtWorks. Along with being cross platform, it supports many popular languages such as Ruby, Java, C#, Python etc.

Gauge is a cross-platform test automation tool that makes use of markdown for developing test cases along with test scenarios. A markdown is an effortless markup language that helps in formatting plain text. It is a way of styling text on the web, with markup you can bold, italic your plain text, you can add bullets, headers, footers and soon. Markdown is used commonly today because of the way it is written. It helps to transfer the code or text across various platforms and applications such as mobile, a browser etc. Earlier the same process required a word application. Gauge, therefore, takes advantage in a similar way. Gauge has also been appreciated by the testers community and developers community for optional support of the IDEs i.e. Gauge tests can also be used by command line support with the continuous integration software like Jenkins.  

Gauge and web drivers

A web driver is a web automation framework that allows you to execute your tests against different browsers.  In simpler terms, we use a web driver to see that we are getting what we expect in our web application.  Selenium is one such web driver. Selenium automatically simulates the user entries in a selected web browser. Selenium is used most commonly for this purpose and Gauge suits it for providing a framework for testing.  So you can set up your framework with Selenium quite easily and run your tests with its help.

Why Gauge?

Gauge provides parallel execution. Similar to the parallel processing in processors, parallel execution can help us run big automated tests in a simple and quick manner. Gauge has many pros on its side which makes it one of the best choices for the developers and testers.

  • Gauge is available in single binary and there is no pre-requisite required. This single binary can be used on all platforms.
  • Gauge is available with many templates to just start and run your project. It has reduced the automation framework setup time reasonably well.
  • Gauge has tremendously easy syntax to learn and write. As discussed above it uses markdown format which is very friendly for a tester.
  • Gauge supports internationalization by default. It can help you write the specs in the language you prefer in your business which need not be English
  • The reusability of Gauge is one of the main features which makes it stand apart. We can reuse the steps from one scenario to another scenario. We can also define steps to run before each scenario while writing the specifications.
  • Gauge has huge support of plugins. Plugins in gauge can be written in any language of your choice and can be used to extend its functionality.
ALSO READ
How to evaluate a dating app before spending a lot of time and money

After all these features it is quite clear that Gauge is a powerful tool and is important in the industry today.

Gauge for TDD and BDD

TDD is Test Driven Development in which the requirements are converted to the test cases in a particular language in which the tests will be done. This is performed on a very short development cycle but with a very wide test coverage (almost 95%) which makes the development and maintenance of the code easy. The following sequence is used in the TDD approach

  • Add a test
  • Run all the test and see if the new code fails
  • Write new tests
  • Run it
  • Refactor
  • Repeat

BDD or Behavior Driven Development is born from TDD techniques. BDD or Behavior-Driven Development uses the basic principle and techniques of TDD but the main power of BDD is that the management and development teams collaborate for software development. Here the implementation is not tested but the behavior. The main focus is not the implementation but the scenario in a BDD approach. Needless to say, if non-technical and technical teams are sitting together, the language used is natural like English-like language sentence.

This approach is most popular and BDD approach is supported by Gauge. Gauge framework as we discussed above uses the scenarios in Behaviour driven approach.  Gauge framework’s support and strength of command line interface help to provide the test cases in the business language. Since BDD is used along with the TDD and unit testing, Gauge serves as a perfectly reliable tool for testing purposes in BDD and TDD.         

Advantages of Gauge

Apart from the key features, we discussed above in the section “Why to use Gauge”. Gauge comes with many advantages for the testing and development team.


  • Gauge uses data store concept which means global data can be passed in different steps in different classes at runtime. This is a much-appreciated feature among the development team.
  • No Parse logic for larger files. Gauge framework does not require to write the parsing logic for large files, instead, the data can be simply passed by files and tables.
  • Easy Reporting. Gauge framework provides easy and convenient HTML reports to study after the test run. No addition step code is required for generating the reports in Gauge.
  • Run Failed test alone. Gauge framework provides the ability to run the failed test alone.
  • Unique step implementation. Gauge framework allows us to develop one step implementation which can then be used in the whole project.
  • Platform independent. Gauge is platform independent.

All the above features and advantages come as an open source in Gauge.

Gauge for cross browser compatibility

Cross Browser testing is a process of testing a web app or a website on different browsers running on a variety of operating systems with respect to the device being used to access the application.  However, maintaining a library of browsers and devices could be very strenuous. After all, you are targeting customers from all over the internet. This is where cross browser testing tools like LambdaTest comes into play, so you could test your application over thousands of browsers and browser versions through virtual machines running over their cloud servers for cross browser compatibility.  

ALSO READ
What is anchor text and how you should use it on your blog

Gauge is today gaining popularity more than ever in this Cucumber dominated area of cross browser testing. Being developed by ThoughtWorks, the same group that brought Selenium, Gauge offers compatibility with Selenium webdriver. For testing on different browsers, we can combine the power of Gauge to Selenium and create a perfect testing suite for our application to run it in different browsers for cross browser testing.  While Gauge supports many languages and templates along with the plugins, it is easy to learn syntax makes it super easy for anyone to develop and run the test suites for his website. While this was earlier done only by the technical persons, Gauge has made it easier to develop these test suites by non-technical persons too. By this, test suites are even created before the coding is done. While time plays an important role for every company and person, Gauge provides the most time efficient solution for testing your website on different platforms with an easy code.

This is a simple test suite written in Gauge for a customer sign up. The following lines represent the specs written in gauge framework.

Customer sign-up
================

* Go to sign up page

Customer sign-up
—————-
tags: sign-up, customer

* Sign up a new customer with name “Harish” email “harish@lambdatest.com” and “password”
* Check if the sign up was successful

These steps are needed to be linked to the Java functions. This is done using the @Step annotation in Java.

public class CustomerSignup {

    @Step("Sign up as <customer> with email <harish@lambdatest.com>
and <password>")

    public void registerCustomerWith(String customer, String email, String password) {

        WebDriver webDriver = Driver.webDriver;

        WebElement form = webDriver.findElement(By.id("new_user"));

        form.findElement(By.name("user[username]")).sendKeys(customer);

        form.findElement(By.name("user[email]")).sendKeys(email);

        form.findElement(By.name("user[password]")).sendKeys(password);

        form.findElement(By.name("user[password_confirmation]")).sendKeys(password);

        form.findElement(By.name("commit")).click();

    }

    @Step("Check if the sign up was successful")

    public void checkSignUpSuccessful() {

        WebDriver webDriver = Driver.webDriver;

        WebElement message = webDriver.findElements(By.className("message"));

        assertThat(message.getText(), is("You have been
signed up successfully!"));

    }

}

The above code snippet is shown to make you familiar with how Markdown syntax of Gauge is converted to the Step annotation in Java. You just have to pass the parameters and the code will be ready.

Conclusion

So summarizing this article, Gauge is an open source BDD tool (while the official website likes not to focus on BDD) which comes with tons of features and advantages. Gauge framework has been vogue in the IT industry & as a result, there is also an increase in the plugin development which is the main strength of any software. In the field of cross browser testing one can use online platforms such as LambdaTest where it is easier and convenient to test on 2000+ browsers in real time with reports and screenshots. Gauge can be combined with selenium for achieving the same purpose. A platform independent and supported by many languages, this framework is definitely worth exploring, using and learning.


>
Share This