Skip to content

Xray-App/tutorial-js-cypress-cucumber

Repository files navigation

Tutorial with Cypress tests, in JavaScript, using Cucumber, integrated with Xray

build workflow license Gitter chat

Overview

Code that supports the tutorial Testing using Cypress and Cucumber in JavaScript showcasing the integration between Xray Test Management on Jira and Cypress.

The test automation code implements some UI tests for doing authentication, targeting a dummy website having a login page. It uses two stories (i.e. login and logout) as the features we aim to deliver.

Prerequisites

In order to run this tutorial, you need to have Cypress and Node.js. Dependencies can be installed using:

npm install

Running

The straighforward approach to run everything in a single shot is to invoke the auxiliary script run_all_cloud_standard_workflow.sh. You need to update the client_id and client_secret to interact with your Xray cloud instance (obtainable from Xray API Keys section); you also need to update the issue keys of the corresponding stories in Jira, that you'll use as basis to generate the .feature file(s).

Remember that to be able to run the scenarios, we need to have the corresponding .feature files. The previous script assumes you are using Xray to manage the specification of the scenarios, so you need to extract them from Jira (more on the possible workflows here).

When you have the .feature files, containing the Feature along with the Scenario properly tagged, you can finally run the tests using the cypress tool (directly or through npm).

npx cypress run --spec 'features/**/*.feature'

or simply

npm test

Tests can also run inside a Docker container; local directory/file should be mounted so that Cucumber results are stored locally.

docker build . -t cypress_cucumber_tests
docker run --rm -v $(pwd)/cucumber-report.json:/source/cucumber-report.json -t cypress_cucumber_tests

The processing of Gherkin .feature files is possible using cypress-cucumber-preprocessor, which can generate Cucumber JSON reports. Cypress can take screenshots and these will become available in the Cucumber JSON reports automatically, and can be later seen in Xray.

Submitting results to Jira

Results can be submitted to Jira so that they can be shared with the team and their impacts be easily analysed. This can be achieved using Xray Test Management as shown in further detail in this tutorial. This repo contains an auxiliary script import_results_cloud.sh that does that; it uses a configuration file to have Xray's client_id and client_secret. You can also have a look at the workflows implemented in this repo using GitHub Actions.

Auxiliary scripts

This repo also contains some auxiliary shell scripts, provided as an example; feel free to download and customize them to your needs. You may find scripts for interacting both with Xray server/DC or Xray cloud, which have slightly different APIs.

Contact

Any questions related with this code, please raise issues in this GitHub project. Feel free to contribute and submit PR's. For Xray specific questions, please contact Xray's support team.

References

LICENSE

BSD 3-Clause