Cucumber

Testing Infrastructure

About

Cucumber is a Behavior Driven Design (BDD) framework that takes “stories” or scenarios written in human readable languages such as English and turns those human readable text into a software test. This makes what is called an “Executable Specification”.

Example

Example based on Selenium

Scenario: Finding some cheese
  Given I am on the Google search page
  When I search for "Cheese!"
  Then the page title should start with "cheese"

Translate into:

package com.example;

public class ExampleSteps {
    private final WebDriver driver = new FirefoxDriver();

    @Given("^I am on the Google search page$")
    public void I_visit_google() {
        driver.get("https://www.google.com");
    }

    @When("^I search for \"(.*)\"$")
    public void search_for(String query) {
        WebElement element = browser.findElement(By.name("q"));
        // Enter something to search for
        element.sendKeys(query);
        // Now submit the form. WebDriver will find the form for us from the element
        element.submit();
    }

    @Then("^the page title should start with \"(.*)\"$")
    public void checkTitle() {
        // Google's search is rendered dynamically with JavaScript.
        // Wait for the page to load, timeout after 10 seconds
        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
          public Boolean apply(WebDriver d) {
          return d.getTitle().toLowerCase().startsWith("cheese");
          }
        });
        assertThat(driver.getTitle(), startsWith("cheese"));
        // Should see: "cheese! - Google Search"
    }

    @After()
    public void closeBrowser() {
        driver.quit();
    }
}





Discover More
Javascript Test - Runner

in Javascript. See also: Winner: Jest because: it's fully integrated in my IDE it supports React out of the box it can also test Typescript it forces you to not start a browser to test...
Testing Infrastructure
Software Quality - Library

Gauge is a light weight cross-platform test automation tool. It provides the ability to author test cases in the business language. ...



Share this page:
Follow us:
Task Runner