Cucumber Integration

Applies to Zephyr Scale Cloud, last modified on April 02, 2021.

Cucumber is a tool that supports Behaviour-Driven Development(BDD). If you’re new to Behaviour-Driven Development read our BDD introduction first.

Cucumber reads executable specifications written in plain text and validates that the software does what those specifications say. The specifications consists of multiple examples, or scenarios. For more info on Cucumber, see here

The Zephyr Scale/Cucumber Workflow

If you’re using Cucumber, Zephyr Scale allows you to tightly integrate with your automated tests. You can write BDD test cases (gherkin scripts) in Zephyr Scale and use a simple script to export these tests when running a build before sending the results back to Zephyr Scale. 

The below diagram shows how this works. 

Using with CI server (e.g. Jenkins) 

 

 

Annotating Cucumber tests in a Zephyr Scale development project enables results from Cucumber to be sent directly to Jira. All it takes is a simple annotation.

Writing Cucumber tests

Cucumber tests are written in Gherkin - a set of grammar rules that makes plain text structured enough for Cucumber to understand. 

Gherkin documents are stored in .feature text files and are typically versioned in source control alongside the software. See the Gherkin reference for more details.

Firstly, the JSON output format for Cucumber needs to be configured on the TestRunner class:


@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/test/resources/calculatorFeatures"
        ,glue={"com/adaptavist/tm4j/cucumberExample/stepDefinition"}
        ,plugin = {"junit:target/cucumber/result.xml", "json:target/cucumber/calculator.json"}
)

public class TestRunner {

}

On the example above, both JUnit XML and JSON output are enabled.

The next step is to add a tag to your scenarios @TestCaseKey=ABC-T123 or do not annotate at all, if the Test Case doesn't exist yet.


Feature: Calculator

  @TestCaseKey=ABC-T123
  Scenario: Add a number
    Given a calculator I just turned on
    And I add 4 and 4
    Then the result is 8

Uploading results to Zephyr Scale

Now, you can run your tests with mvn test and the Cucumber execution results will be generated in target/cucumber/*.json.

Mapping a status to Zephyr Scale

We now support all Cucumber statuses. They will map automatically to an existing status or show as Blocked if a matching custom status doesn't exist.

Code samples

SmartBear/zephyr-scale-cucumber-example 

Suggested Improvements

Is something missing? If you’d like to suggest an improvement to this integration, take a look at our Ideas Portal

You can search for existing ideas or create your own. We review ideas regularly and will take them into account for future development. 

Highlight search results