Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Get to Know Gauge, the New Cross-Browser Testing Framework

DZone's Guide to

Get to Know Gauge, the New Cross-Browser Testing Framework

Learn about Gauge, a new BDD-based test framework, and how it fills a gap in the cross-browser testing market.

· Mobile Zone ·
Free Resource

Just like Rihanna, you might think there are too many frameworks to learn in the testing arena! Now there is a new cross-browser test framework gaining adoption in the community: Gauge, a framework sponsored by ThoughtWorks. It seems to be attracting significant attention and traction in a testing community typically dominated by Cucumber framework and Selenium.

While both Cucumber and Selenium have been around for years and are currently the preferred testing frameworks for agile teams, we are finding that more teams are adopting Gauge throughout the DevOps pipeline.

So why is a market for another framework? Are there benefits for a Development Manager, a Developer or a Test Engineer? How does Perfecto work with Gauge?

About Gauge

  1. What is Gauge? It is a new BDD (behavior driven development) based test framework.
  2. How does it work? Gauge seamlessly integrates with IDEs (i.e. IntelliJ) and CI servers (i.e. Jenkins) for cross functional team collaboration and continuous testing throughout the DevOPS cycle.
  3. What is unique about Gauge? It offers simple but sophisticated code that is written in languages such as Java. It is also simple to setup, customize and expand, has a clear and logical step/scenario construct, is fast to execute tests and it offers abstraction mechanisms.

Image title

Why There Is a Market for the Gauge Framework

  1. Allows both skilled developers and non-developers to utilize it due to its simplicity for authoring, managing and executing tests
  2. Allows cross-browser testing teams to find and fix a bug right before release vs. releases with a bug or delaying releases
  3. Testing can be ready before coding > the realization of agile and the shift left movement

Benefits for a Development Manager

  1. Introducing stable & scalable test scripts early in the sprint
  2. Innovate faster and test coverage can expand
  3. Empowers the rest of the team to help
  4. Streamlines process – more efficient and productive – hopefully eliminating late-discovered defects resulting in delaying launch or launching with a defect

Benefits for Developers

  1. Gain insight into defects as they generate code
  2. Their time is being used to match their skill level
  3. Full synchronization around product requirements across the board (QA, Business & Dev)

How to Use the Perfecto Cloud Platform With the Gauge Framework

Perfecto’s cloud platform, consisting of real mobile devices and virtualized desktop browsers located in global locations, is easily extensible and is integrated with various open source frameworks. In fact, Perfecto endorses its own open source framework, Quantum.

Integrating Gauge with Perfecto offers testing of any browser in a cloud environment. A typical tester would struggle to have scalable access to all operating systems, browsers and browser versions used by end users. Furthermore, testers need to test beta versions of browsers as occasionally those include significant changes coming soon to production. Perfecto’s cloud offers exactly that: a variety of environments offered in enterprise-grade in clear and ready fashion, such that scalable amounts of concurrent tests can execute in a stable manner with predictable outcomes.

Integration strategy: A new class is introduced, called “Perfecto Helper”. Inside that class there’s a static RemoteWebDriver and a ReportiumClient. Those are created on the initiation of each specification. In terms of managing test status, each test class (Java) should start the test as part of the Java class constructor:

public void GoogleTest() {
 DriverFactory.getReportiumClient().testStart(“Example Perfecto Gauge Google Test”, new TestContext(“Google”, “Gauge”));
}

*Note that it is possible to customize the test name and add tags. it is also recommended to capture exceptions and pass those to the ReportiumClient, as below:

@Step(“On the homepage”)
public void navigateToHomePage() {
  try {
   DriverFactory.getDriver().get(“https: //www.google.com”);
   } catch (Exception e) {
    setTestResultFailed(e);
    e.printStackTrace();
   }
  }
  private void setTestResultFailed(Exception e) {
   DriverFactory.setExceptionInformation(e);
  }



PerfectoHelper represents a new driver based on the following parameters:

*Optional parameters. Their default value is defined in env/default/default.properties and their value is as shown in the example.

Image title

Running the first time:

  • Enter your Perfecto cloud, username and security token into env/default/default.properties
  • Right click “GoogleTest.spec” and select “Run”
  • The test should run in Perfecto
  • You should see a line in the console “Report URL:” with a link to the report in Perfecto, which you can open separately.

Now that you’ve run a single test, you can run two specs by selecting the folder “specs”, right click and run. Note that the tests will run serially.

Customizing the environments: Testers can override one or more of these parameters either by modifying the values in default.properties, or creating a new folder under env/<name> and adding a .properties file under it. You only need to define the parameters you want to override; the rest will use the default values. If you’re using IntelliJ, you can also define variables in Run->Edit configurations.

To execute tests using a specific configuration (also called ”environment”), go to Run->Edit configurations, in “Environment” box enter the name of the folder under env you customized.

To get started with Gauge and Perfecto, please refer to the GIT repository.

Limitations:

  • It appears that inside IntelliJ it is impossible to run more than one environment simultaneously. This can probably be done from your CI tool.
  • It also appears that Gauge does not support safe parallel execution of specs inside IntelliJ, since the driver is static and needs to be shared between the scripts. The same comment about the CI tool applies.

Summing It All Up

Gauge came into the Cross-Browser Testing Framework community about a year ago and they continue to make a significant impact on the way teams are testing. It offers many benefits for agile teams throughout the DevOps process, including ease of use and immediate feedback.

Gauge is still relatively new, and as a result, the open source community continues to improve upon it every day. Overall, Gauge is here to stay and here at Perfecto, we are happy about it. We wish to thank the coders of Gauge, this integration was easy and valuable.

Happy coding and please share your experiences in the comments section below!

Topics:
mobile ,mobile testing ,gauge

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}