Dramatically increase the value of Cucumber with Appvance UTP

Cucumber and Behavior-Driven Development (BDD) are smart choices for software development and QA teams. Combining your existing Cucumber BDD scripts with Appvance UTP super-charges your teams to DevOps speeds—with no additional coding. In the first week, teams can quickly improve test coverage and improve team productivity.

Cucumber and BDD


Download the Tech Brief

Cucumber began in 2011 as an easy-to-use software script runner. Cucumber uses a notation system called Gherkin, a Behavior-Driven Development (BDD) standard, to identify user behavior and build libraries of reusable tests. BDD is especially valuable for describing features using a business-level language. The language fosters effective communication for stakeholders, managers, QA and developers alike. Using Cucumber to automate BDD does, however, require true coding beneath each step description.

From a software developer perspective, Cucumber is a tool used for writing requirements and testing software. It runs automated acceptance tests written in a behavior-driven development (BDD) syntax which calls underlying code to execute each step. Cucumber scripts are automated using the Ruby scripting language as well as a variety of scripting languages.

Appvance UTP and Cucumber

Appvance began demonstrating Cucumber and BDD in its Selenium Workshop for Beginners classes in 2014. Since then, we have watched as Cucumber gained popularity—in 2016, Cucumber achieved up to 120,000 downloads a week.

Combining Cucumber and Appvance UTP delivers the following benefits:

  1. With Appvance Designer (a component of Appvance UTP), it can take only minutes (instead of hours) to fully create and debug complex test scripts for many applications even without coding expertise. These can be used by themselves or as code inside Cucumber BDD. While BDD is great at quickly notating the tests to run and in what order, software developers still need to create the underlying test scripts (code) that interact with Web pages, mobile apps, API calls or RESTful web services. It can also deal with ever-changing applications which can make the underlying code brittle. Appvance Designer can be used by your team in addition to Cucumber.
  2. The Appvance Data Production Library (DPL) in Appvance UTP data-enables your Cucumber tests running on your servers, in the cloud or third-party servers. Cucumber BDD notations describe the operational test data and actions at a high level. For example, a log-in task requires a user name and password. The Appvance DPL can source the data from CSV files, relational/Mongo/Hadoop data sources and web services. The Appvance DPL ensures each Cucumber test uses unique data for each Cucumber user instance and enables the same Cucumber tests to work from development to test and deployment. By data-enabling Cucumber, teams can increase test coverage with little effort almost overnight.
  3. With Appvance UTP, your teams will immediately gain productivity when reusing Cucumber tests beyond their original purpose. because Appvance UTP takes your Cucumber tests beyond unit and functional. With Appvance UTP, you can turn Cucumber tests into security tests (app penetration and DDoS penetration) and performance tests (load, stress, soak, synthetic APM). You can perform browser and mobile device testing with Appvance UTP as well.
  4. Appvance supports a broad range of scripting languages, overlapping those that are supported by Cucumber. Initially, BDD test elements in Cucumber were defined in the Gherkin syntax. When the automation layer was added, features could be described in the Ruby scripting language. Since then, Cucumber has added support for Java, JavaScript, .NET, Groovy, Python, C++ and other languages.

Together, Cucumber and Appvance UTP deliver increased value because:

cucumber

  • Appvance Designer can be used to create tests faster and even re-use tests inside Cucumber
  • Appvance UTP provides the operational test data to a Cucumber test even if the test runs in the cloud a thousand miles away
  • Instantly run a Cucumber test as a Security, Performance, and Compatibility test
  • Appvance UTP tests can be added in a variety of languages, including Java, .NET, Python, and C++

Functional testing with Cucumber and BDD

Let’s say you are operating a bank and need to verify that your banking software operates as expected. Your business analyst writes this requirement:

When an amount has been deposited to a user’s account, the user’s current balance is updated by that amount.

The BDD notation to test the bank software looks like this:

Feature: Depositing money into a user’s account
    Scenario: Depositing money into user’s account should add money to the user’s current balance

        Given a user has no money in their account
        When $100 is deposited in to the account
        Then the balance should be $100

BDD is pretty cool! Not only can business analysts read and understand this notation, they can even write their own requirements. Cucumber makes it easy for a software engineer to develop a feature that follows the notation and QA can implement tests with the same notation.

Data-enable the test in Appvance UTP

Here is an example of how the powerful Appvance DPL (Data Production Library) can data-enable this Cucumber test. In the following, Appvance UTP provides the new account name from the Appvance DPL service:

1.  public class DepositStepDefinitions {
2.    @Given(“^a User has a zero balance in their account$”)
3.    public void a_User_has_no_money_in_their_current_account( UserName name ) {
4.        User user = new User( name );
5.        Account account = new Account();
6.        user.setAccount(account);}]
7.    }
8.  }

Next, we add a method, assert True, to confirm that the new user’s balance is zero:

1.  public class DepositStepDefinitions {
2.    @Given(“^a User has a zero balance in their account$”)
3.    public void a_User_has_a_zero_balance_in_their_account( UserName name ) {
4.        User user = new User( name );
5.        Account account = new Account();
6.        user.setAccount(account);
7.        assertTrue(“The balance is not zero.”, account.getBalance() == 0);
8.    }
9.  }

Running a Cucumber test in Appvance UTP

You can quickly and easily run a Cucumber test using Appvance UTP. Begin by creating a Java class:

1.    package com.c0deattack.cucumberjvmtutorial;
2.
3.    import org.junit.runner.RunWith;
4.    import cucumber.junit.Cucumber;
5.
6.    @RunWith(Cucumber.class)
7.    @Cucumber.Options(format={“pretty”, “html:target/cucumber”})
8.
9.    public class RunTests { }

Then, use the Appvance Scenario Builder to run the class:

Appvance Scenario Builder combining DPL and a Java script runner to execute a  Cucumber test

Appvance Scenario Builder combining DPL and a Java script runner to execute a Cucumber test


Appvance Designer

Appvance UTP allows Cucumber features to interoperate with web and Ajax applications, mobile apps, and RESTful web services. In the previous example, the Cucumber BDD test confirmed the bank account balance using an Appvance Designer script.

Appvance Designer recording a test in a banking application. Appvance Designer saves the recorded test in a variety of Cucumber compatible test types.

Appvance Designer recording a test in a banking application. Appvance Designer saves the recorded test in a variety of Cucumber compatible test types.

The following* is the same test in Java using WebDriver APIs:

1.  public void setAccount( UserName name ) {
2.      WebDriver driver = new FirefoxDriver();
3.      driver.get(“http://ec2-52-88-124-145.us-west-2.compute.amazonaws.com:8888/“);
4.      WebElement element = driver.findElement(By.linkText(“Login”));
5.      element.click();
6.      element = driver.findElement( name.getNameElement() );
7.      element.sendKeys( name.getName() );
8.      element = driver.findElement( name.getNameElement() ));
9.      element.sendKeys( name.getPassword() );
10.    element.submit();
11.    element = driver.findElement(By.linkText(“Balance”));
12.  }

*This example uses Cucumber-Jvm with Cucumber-Java + Cucumber-JUnit Example and Appvance UTP.

Use Appvance UTP to dramatically increase the value of Cucumber

For any CEO, CTO and CIO, we encourage looking at Cucumber paired with Appvance UTP to move your DevOps initiatives forward faster and easier:

  • Agile—clearer definitions of tests for development, QA and business analysts
  • DevOps—faster way to confirm a deployment or integration project succeeded
  • Business Analyst and Software Architect—better definition for web pages, apps, and RESTful web services, and an easier way to run tests that align with your software requirements

Together, Cucumber and Appvance UTP deliver increased value because:

  • Appvance Designer takes minutes instead of days to create the tests Cucumber runs
  • Appvance UTP provides the operational test data to a Cucumber test even if the test runs in the cloud
  • Instantly run a Cucumber test as a Security and Performance test
  • Appvance UTP tests can be added in a variety of languages, including Java, .NET, Python and C#