Our documentation site has been updated to AIO Tests Knowledge Base
Cypress Cucumber via Cucumber JSON report
AIO Tests supports importing Cypress Cucumber results in 2 ways
AIO Tests Cypress reporter - a NPM package plugin for cypress. As a cypress plugin, it can be configured to report results to AIO Tests directly from cypress.
Via Cucumber.json report - The Cypress Cucumber preprocessor not only helps to run Cucumber tests in Cypress but also generates a json report compatible with AIO Tests.
Using the Cypress Cucumber report, scenarios can be mapped to existing cases or new ones can be created from the Cucumber results json file.
This document provides an overview on how you can generate the Junit report from Cypress runs and upload it to AIO Tests.
Required Cypress Setup
Node.js 12 or 14 and above
cd /your/project/path
npm init
npm install cypress --save-dev
npm install @badeball/cypress-cucumber-preprocessor
Download Cucumber Standalone JSON Formatter
Configure your preferred bundler to process features files. See examples/ for how-to using Browserify, Esbuild or Webpack.
For the current example we would be using webpack.
Sample package.json dependencies
"dependencies": {
"@badeball/cypress-cucumber-preprocessor": "^12.1.0",
"@cypress/webpack-preprocessor": "latest",
"cypress": "^10.6.0"
},
Sample Cucumber Scenario
Gherkin uses a set of keywords to formalize a behavior. Most lines start with one of the keywords.
Cucumber tests can be structured as Features. A feature can look at encapsulating a particular functionality of a system.
Features are made of Scenarios, which are essentially different user flows of the functionality being tested.
Scenarios are made of Steps. Each step starts with Given
, When
, Then
or And
.
Feature: Capture the number of trees planted and show relation to global warming
@P0
Scenario: Trees effect on global warming
Given There are no trees numbered in a given region
When Each user plants a tree and updates
Then The temperature is updated in the temperature log
When Temperature is captured over a few days
Then The graph should show the relation between the number of trees and temperature
Running Cucumber tests
Configure
specPattern
with"**/*.feature"
, incypress.config.js
.import { defineConfig } from "cypress"; export default defineConfig({ e2e: { specPattern: "**/*.feature" } });
Configure your preferred bundler to process features files. Below example uses Webpack.
Run your tests
cypress run --spec cypress/e2e/*
Generating Cucumber.json report
This requires you to have downloaded and installed the cucumber-json-formatter as shown in the setup. Add the downloaded formatter to your
PATH
.JSON reports can be enabled using the
json.enabled
property in package.json. Add the below to your package.json
3. Register the cypress-cucumber-preprocessor module in your cypress.config.js as below:
The report is written to cucumber-report.json
in the project directory, but can be configured through the json.output
property.
Consolidated Cypress config file
Screenshots in report
Screenshots are automatically added to JSON reports, including that of failed tests (unless you have disabled screenshotOnRunFailure
). However, while importing, AIO Tests only imports artifacts for failed cases.
Cucumber Sample JSON Report
The JSON report generated by Cucumber gives a detailed step by step report as follows :
Status Mapping Cucumber → AIO Tests
For understanding the status mapping from Cucumber results to AIO Tests run statuses, please refer to
Mapping Cucumber tests to AIO Tests
To understand how to map automated cases to cases in AIO Tests, please refer to https://aioreports.atlassian.net/wiki/spaces/NAT/pages/1900879638/Cucumber#Mapping-Cucumber-tests-to-AIO-Tests
Importing Results
Post execution of cucumber tests, the result file can be imported to AIO Tests via the REST APIs or the Jenkins plugin or manually via the Cycles screen. Read about all possible options @ https://aioreports.atlassian.net/wiki/spaces/NAT/pages/1900879961