为 WebdriverIO/Cucumber 框架生成 HTML 报告 [英] Generate HTML report for WebdriverIO/Cucumber framework
问题描述
我正在使用
希望这有帮助.干杯!
<小时>注意:当我有更多时间使用其他很棒的方法从您的 WebdriverIO 报告器日志生成报告时,我会尝试更新这篇文章,特别是如果这篇文章在此过程中获得了一些喜爱/赞许.
例如:另一个我喜欢使用的组合是:wdio-json-reporter
/wdio-junit-reporter
加上一个简单的-使用模板语言,Jinja2.
I am using WebdriverIO/Cucumber (wdio-cucumber-framework
) for my test automation. I want to get the test execution result in a HTML file. As of now I am using Spec Reporter (wdio-spec-reporter
). Which helps to print the results in console window. But I want all the execution reports in a HTML file.
How can I get WebdriverIO test execution result in a HTML file?
Thanks.
OK, finally got some spare time to tackle your question @Thangakumar D. WebdriverIO reporting is a vast subject (there are multiple ways to generate such a report), so I'll go ahead and start with my favorite reporter: Allure!
- [Preface: make sure you're in your project root]
- Install your package (if you haven't already):
npm install wdio-allure-reporter --save-dev
- Install Allure CommandLine (you'll see why later):
npm install -g allure-commandline --save-dev
- Setup your
wdio.config.js
file to support Allure as a reporter
wdio.config.js:
reporters: ['allure', 'dot', 'spec', 'json'],
reporterOptions: {
outputDir: './wdio-logs/',
allure: {
outputDir: './allure-reports/allure/'
}
}
- Run your tests! Notice that, once your regression ends, your
/allure-results/
folder has been populated with multiple.json
,.txt
,.png
(if you have screenshot errors), and.xml
files. The cotent of this folder is going to be used by Allure CommandLine to render you HTML report. - Go to your
/allure-results/
folder and generate the report via:allure generate <reportsFolderPath>
(do it like thisallure generate .
- If you want your
/allure-reports/
folder inside/allure-results/
) - Now go into your
/allure-reports
folder and opeindex.html
into your browser of choice (use Firefox for starters)
Note: The generated index.html
file won't have all the content loaded on Chrome unless you do some tweaks. It's due to default WebKit not being able to load all the AJAX calls required. Read more about it here.
If you're successfully completed all the previous steps, it should look something like this:
Hope this helped. Cheers!
Note: I'll try to UPDATE this post when I get some more time with other awesome ways to generate reports from your WebdriverIO reporter logs, especially if this post gets some love/upvotes along the way.
e.g.: Another combo that I enjoy using being: wdio-json-reporter
/wdio-junit-reporter
coupled with a easy-to-use templating language, Jinja2.
这篇关于为 WebdriverIO/Cucumber 框架生成 HTML 报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!