...
Produce JSON result files using cucumber-json-preprocessor.Transform your JSON result files into one result file accepted by Cucumber for Jira
Push every results file using cURL command
1. Produce JSON result files using cucumber-json-preprocessor
...
Subset of result file for the Bad Usage feature
Code Block | ||
---|---|---|
| ||
[ { "id": "bad-usage", "uri": "features/bad_usage.feature", "keyword": "Feature", "name": "Bad usage", ... } ] |
Subset 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 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", ... } ] |
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 |
---|
[] |
Copy all the result file content for Bad Usage between the brackets into the newly created JSON file:
Code Block |
---|
[
{
"id": "bad-usage",
"uri": "features/bad_usage.feature",
"keyword": "Feature",
"name": "Bad usage",
...
}
] |
Repeat the second operation for the content of every 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:
...
2. Push every results file using cURL command
We suppose your results files were generated in reports
folder. The command will looks for every JSON file in the reports
folder and send each of them using cURL command to Cucumber for Jira
Code Block | ||
---|---|---|
| ||
find reports/*.json -exec curl -X POST https://c4j.cucumber.io/ci/rest/api/results -H 'authorization: $ACCESS_TOKEN_HERE' -H 'content-type: multipart/form-data' -F 'results_files[]'=@\"{}\" -F language=js; |
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.
...