Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber HTML report with Protractor

I am using Protractor with Cucumber (js). I would like to generate report files just like with the Cucumber-JVM version. I have seen examples when using Protractor with Jasmine, but practically nothing with Cucumber.

How do you generate reports when using this configuration?

The final goal is to publish this report in Jenkins, or anywhere else if they are directly generated in HTML.

Thanks!

like image 500
Pedro Lopez Avatar asked Aug 04 '14 09:08

Pedro Lopez


People also ask

How do you draw a report on a protractor cucumber?

Show activity on this post. Take a browser screenshot after each failed scenario to be attached to the json report in the After-hook. Write the test results to a json-file even if your cucumber opts format property says 'pretty'. Convert the json report to HTML, including screenshots for failed scenarios.

How do I use multiple cucumber reporters in HTML?

To use Multiple Cucumber HTML Reporter it must be run in a separate node executable after the cucumber-js process finishes. IMPORTANT: Make sure that, when you generate the JSON files with Cucumber, each file will have a UNIQUE name. If you don't provide a unique name Cucumber will override the JSON files.


1 Answers

With the latest version of protractor (from version 1.5.0), you can now generate a JSON report. When I asked this question about 7 months ago that feature was not there.

All you need to do is add this to your protractor-config.json file.

resultJsonOutputFile: 'report.json'

Where report.json is the location of the output file.

Once you have that, you can use protractor-cucumber-junit (https://www.npmjs.com/package/protractor-cucumber-junit), cucumberjs-junitxml (https://github.com/sonyschan/cucumberjs-junitxml) or something similar to transform the JSON file into a valid XML file that Jenkins can display.

$ cat report.json | ./node_modules/.bin/cucumber-junit > report.xml

Hope this helps.

like image 82
Pedro Lopez Avatar answered Oct 13 '22 00:10

Pedro Lopez