Our documentation site has been updated to AIO Tests Knowledge Base

Cypress via JUnit file

Cypress, an end to end JavaScript based framework, is built on Mocha, which supports a number of reporting formats.

AIO Tests supports importing Cypress results in 2 ways

  1. 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.

  2. Via JUnit reports - Cypress has added native support for the commonly used Mocha reporters, one of them being JUnit. The JUnit xml file can then be imported into AIO Tests, to report results from Cypress runs to AIO Tests.

    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

  1. Node.js 12 or 14 and above

  2. cd /your/project/path

  3. npm init

  4. npm install cypress --save-dev

Mapping Cases with AIO Tests

The below is just a sample test file, which opens the Jira cloud URL and logs in, with simple assertions.

AIO Tests supports creating tests using Junit reports as well as mapping existing cases.

Mapping existing AIO Tests to automated Cypress Tests

AIO Tests generates a unique key for each test created in AIO Test, example SCRUM-TC-1. To map an automated case to an existing AIO Test, the it() can take the testcase key generated in its description. e.g.it('AT-TC-299 : Login to jira', () => {....}

In the example below, two existing AIO Tests have been mapped to two different cypress tests.

This would pull AT-TC-299 and AT-TC-300 in the execution cycle and mark the result of each of these tests i.e.

“Login to Jira” against AT-TC-299

“Forgot password flow” against AT-TC-300

// jira_navigation.js created with Cypress // // If you're unfamiliar with how Cypress works, // check out the link below and learn how to write your first test: // https://on.cypress.io/writing-first-test describe('Navigation', () => { it('AT-TC-299 : Login to jira', () => { cy.visit("https://yourcompany.atlassian.net") cy.contains('Continue') cy.get('#username').type('youremail@email.com') cy.get('#login-submit').click() cy.get('#password').type('<yourpassword>') cy.get('#login-submit').click() expect(true).to.equal(false) }) it('AT-TC-300 :Forgot password flow', () => { cy.visit("https://yourcompany.atlassian.net") cy.contains('Continue') cy.get('#resetPassword').click() expect(true).to.equal(true) }) it('Cancel Forgot password flow', () => { cy.visit("https://yourcompany.atlassian.net") cy.contains('Continue') cy.get('#resetPassword').click() expect(true).to.equal(true) cy.get('#cancel').click() }) })

Creating new cases in AIO Tests from automated Cypress Tests

If no new key is specified in the spec, then new cases can be created using the results of the tests.

While importing results, if the Create New Case selection is true, then AIO Tests will use the classname.methodname e.g. in the above case, from the Junit results file as a unique automation key to identify the test to AIO Tests.

AIO Tests key would still be generated of the format SCRUM-TC-xyz, which can then be added to the it() name. This would ensure that changes to the description do not end up creating cases where new cases were not intended.

Configuration and Running with Junit reporter using CLI

Since Cypress has added native support for JUnit, no new dependencies need to be added to generate the JUnit report. However, the report options can be customized in the cypress.json file as below:

"reporterOptions": { "mochaFile": "results/test-output-[hash].xml", }

If you need multiple reporters, then the mocha JUnit reporter needs to be separately installed. More details can be found @ Cypress Multiple Reporters

Now, we can run the above sample file with the following command. Please note, that the reporter needs to be specified as Junit.

cypress run --reporter junit --spec "cypress/integration/jira_navigation.js"

 

Sample report file

The spec file runs and generates a test-output file under the results folder. A sample JUnit results file looks like below:

Importing Results

Post execution of a JUnit suite, the TEST-<xxx>.xml file can be uploaded either via

Please follow the above links to continue to import results using either of the options.

Importing the above file will mark AT-TC-299 and AT-TC-300 as Passed in the cycle.

A new case would be created with title Navigation Cancel Forgot password flow and added to the cycle with a result of Failed.