Cucumber for Jira is only supporting JSON results of generated from official cucumber implementations. But there is a trick to be able to push results from CypressHowever you can also upload results generated from Cypress with 2 additional steps.
Cucumber for Jira is using this JSON schema to validate the JSON uploaded result file received. Which This means that if we can produce something that is validated by any result file validated against this schema , we will be able to push it in accepted by Cucumber for Jira.
That’s possible in 2 steps:
Produce a JSON result files using cucumber-json-preprocessor.
Create a valid JSON result file
...
Transform your JSON result files into one result file accepted by Cucumber for Jira
1. Produce JSON result files using cucumber-json-preprocessor
Please follow installation and configuration steps described in the homepage of cucumber-json-preprocessor
...
.
Let say we have two feature files : Bad Usage and Serve Coffee bad_usage.feature and serve_coffee.feature
Code Block |
---|
Feature: Bad Usage |
Code Block |
Feature: Serve Coffee |
Cypress with cucumber-json-preprocessor
Cypress Executing your test after configuring cucumber-json-preprocessor will produce 2 result files: one result file per feature. You will end up with a file containing
Subset of result file for the Bad Usage feature
Code Block | ||
---|---|---|
| ||
{ "id": "bad-usage", "uri": "features/bad_usage.feature", "keyword": "Feature", "name": "Bad usage", ... } |
And the other one will containSubset of result file for the Serve Coffee feature
Code Block | ||
---|---|---|
| ||
{ "id":"serve-coffee", "uri":"features/serve-coffee.feature", "keyword":"Feature", "name":"Serve Coffee", ... } |
...
2. Transform your JSON result files into one result file accepted by Cucumber for Jira
Cucumber for Jira expects an array of feature result objects.
What we are expecting
results as shown below
Code Block | ||
---|---|---|
| ||
[ { "id": "bad-usage", "uri": "features/bad_usage.feature", "keyword": "Feature", "name": "Bad usage", ... }, { "id":"serve-coffee", "uri":"features/serve-coffee.feature", "keyword":"Feature", "name":"Serve Coffee", ... } ] |
Generate a valid JSON result file
...
So you need to aggregate the content of each result file produced by cucumber-json-preprocessor in a single JSON file. These are the steps you should follow in the above example with our 2 feature files
Create a new JSON file with the following content :
Code Block []
I copy content of Bad Usage result file in Copy all the result file content for Bad Usage between the brackets into the newly created JSON file inside the array:
Code Block [ { "id": "bad-usage", "uri": "features/bad_usage.feature", "keyword": "Feature", "name": "Bad usage", ... } ]
I repeat Repeat the second operation for the content of every results generated ( don’t forget to separate object with a comma )result file generated cucumber-json-preprocessor. In our example, the result file content for the Serve Coffee feature
Pay attention to add a comma between each result file content as follow:Code Block [ { "id": "bad-usage", "uri": "features/bad_usage.feature", "keyword": "Feature", "name": "Bad usage", ... }, { "id":"serve-coffee", "uri":"features/serve-coffee.feature", "keyword":"Feature", "name":"Serve Coffee", ... } ]
Voilà! You should be able to upload the consolidated JSON file into Cucumber for Jira.
You could automate these steps to include them in a CI tool.