前提
已经熟练掌握了Cypress的基本知识,请参考自动化测试框架[Cypress概述]和自动化测试框架[各自动化测试框架比较]
已经熟练掌握Cypress环境配置,请参考自动化测试框架[Cypress环境搭建与配置详解]
和自动化测试框架[Cypress测试实例凸显其优势]
已经熟练掌握Cypress框架结构,请参考自动化测试框架[Cypress框架拆解]
和自动化测试框架[Cypress重试机制]
已经熟练掌握Cypress内置测试报告,请参考自动化测试框架[Cypress内置测试报告详解]
已经熟练掌握Cypress内置测试报告,请参考自动化测试框架[Cypress自定义测试报告详解]
下载并配置Allure
通过Allure下载
下载解压后,将bin路径添加到系统环境变量中


环境验证

在命令行直接执行allure

C:\Users\Administrator>allure
Usage: allure [options] [command] [command options]
Options:
--help
Print commandline help.
-q, --quiet
Switch on the quiet mode.
Default: false
-v, --verbose
Switch on the verbose mode.
Default: false
--version
Print commandline version.
Default: false
Commands:
generate Generate the report
Usage: generate [options] The directories with allure results
Options:
-c, --clean
Clean Allure report directory before generating a new one.
Default: false
--config
Allure commandline config path. If specified overrides values from
--profile and --configDirectory.
--configDirectory
Allure commandline configurations directory. By default uses
ALLURE_HOME directory.
--profile
Allure commandline configuration profile.
-o, --report-dir, --output
The directory to generate Allure report into.
Default: allure-report
serve Serve the report
Usage: serve [options] The directories with allure results
Options:
--config
Allure commandline config path. If specified overrides values from
--profile and --configDirectory.
--configDirectory
Allure commandline configurations directory. By default uses
ALLURE_HOME directory.
-h, --host
This host will be used to start web server for the report.
-p, --port
This port will be used to start web server for the report.
Default: 0
--profile
Allure commandline configuration profile.
open Open generated report
Usage: open [options] The report directory
Options:
-h, --host
This host will be used to start web server for the report.
-p, --port
This port will be used to start web server for the report.
Default: 0
plugin Generate the report
Usage: plugin [options]
Options:
--config
Allure commandline config path. If specified overrides values from
--profile and --configDirectory.
--configDirectory
Allure commandline configurations directory. By default uses
ALLURE_HOME directory.
--profile
Allure commandline configuration profile.
执行Cypress测试用例
生成junit报告
首先在cypress.json文件中添加如下配置
{
"reporter": "junit",
"reporterOptions": {
"mochaFile": "results/test_report_[hash].xml",
"toConsole": true
}
}
执行测试
D:\Cypress>npm run cypress:run
> davieyang@1.0.0 cypress:run D:\Cypress
> cypress run
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 6.2.0 │
│ Browser: Electron 87 (headless) │
│ Specs: 19 found (examples\actions.spec.js, examples\aliasing.spec.js, examples\assertions │
│ .spec.js, examples\connectors.spec.js, examples\cookies.spec.js, examples\cypress_ │
│ api.spec.js, examples\files.spec.js, examples\local_storage.spec.js, examples\loca │
│ tion.spec.j...) │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\actions.spec.js (1 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 14 │
│ Passing: 14 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 28 seconds │
│ Spec Ran: examples\actions.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\actions.spec.js.mp4 (8 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\aliasing.spec.js (2 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 2 │
│ Passing: 2 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 5 seconds │
│ Spec Ran: examples\aliasing.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\aliasing.spec.js.mp4 (1 second)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\assertions.spec.js (3 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 9 │
│ Passing: 9 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 10 seconds │
│ Spec Ran: examples\assertions.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\assertions.spec.js.mp4 (3 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\connectors.spec.js (4 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 8 │
│ Passing: 8 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 7 seconds │
│ Spec Ran: examples\connectors.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\connectors.spec.js.mp4 (5 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\cookies.spec.js (5 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 5 │
│ Passing: 5 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 7 seconds │
│ Spec Ran: examples\cookies.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\cookies.spec.js.mp4 (3 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\cypress_api.spec.js (6 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 12 │
│ Passing: 12 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 7 seconds │
│ Spec Ran: examples\cypress_api.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\cypress_api.spec.js.mp4 (3 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\files.spec.js (7 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 4 │
│ Passing: 4 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 5 seconds │
│ Spec Ran: examples\files.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\files.spec.js.mp4 (2 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\local_storage.spec.js (8 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 4 seconds │
│ Spec Ran: examples\local_storage.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\local_storage.spec.js.mp (1 second)
4
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\location.spec.js (9 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 3 │
│ Passing: 3 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 5 seconds │
│ Spec Ran: examples\location.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\location.spec.js.mp4 (1 second)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\misc.spec.js (10 of 19)
(node:2996) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 preprocessor:close listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 6 │
│ Passing: 6 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 1 │
│ Video: true │
│ Duration: 8 seconds │
│ Spec Ran: examples\misc.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Screenshots)
- D:\Cypress\cypress\screenshots\examples\misc.spec.js\my-image.png (1000x1800)
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\misc.spec.js.mp4 (4 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\navigation.spec.js (11 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 3 │
│ Passing: 3 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 7 seconds │
│ Spec Ran: examples\navigation.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\navigation.spec.js.mp4 (2 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\network_requests.spec.js (12 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 6 │
│ Passing: 6 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 12 seconds │
│ Spec Ran: examples\network_requests.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\network_requests.spec.js (7 seconds)
.mp4
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\querying.spec.js (13 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 5 │
│ Passing: 5 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 6 seconds │
│ Spec Ran: examples\querying.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\querying.spec.js.mp4 (2 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\spies_stubs_clocks.spec.js (14 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 7 │
│ Passing: 7 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 8 seconds │
│ Spec Ran: examples\spies_stubs_clocks.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\spies_stubs_clocks.spec. (2 seconds)
js.mp4
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\traversal.spec.js (15 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 18 │
│ Passing: 18 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 10 seconds │
│ Spec Ran: examples\traversal.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\traversal.spec.js.mp4 (4 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\utilities.spec.js (16 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 6 │
│ Passing: 6 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 7 seconds │
│ Spec Ran: examples\utilities.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\utilities.spec.js.mp4 (2 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\viewport.spec.js (17 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 6 seconds │
│ Spec Ran: examples\viewport.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\viewport.spec.js.mp4 (2 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\waiting.spec.js (18 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 2 │
│ Passing: 2 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 9 seconds │
│ Spec Ran: examples\waiting.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\waiting.spec.js.mp4 (2 seconds)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: examples\window.spec.js (19 of 19)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 3 │
│ Passing: 3 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 3 seconds │
│ Spec Ran: examples\window.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: D:\Cypress\cypress\videos\examples\window.spec.js.mp4 (1 second)
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ √ examples\actions.spec.js 00:28 14 14 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\aliasing.spec.js 00:05 2 2 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\assertions.spec.js 00:10 9 9 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\connectors.spec.js 00:07 8 8 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\cookies.spec.js 00:07 5 5 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\cypress_api.spec.js 00:07 12 12 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\files.spec.js 00:05 4 4 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\local_storage.spec.js 00:04 1 1 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\location.spec.js 00:05 3 3 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\misc.spec.js 00:08 6 6 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\navigation.spec.js 00:07 3 3 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\network_requests.spec.js 00:12 6 6 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\querying.spec.js 00:06 5 5 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\spies_stubs_clocks.spec.js 00:08 7 7 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\traversal.spec.js 00:10 18 18 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\utilities.spec.js 00:07 6 6 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\viewport.spec.js 00:06 1 1 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\waiting.spec.js 00:09 2 2 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ examples\window.spec.js 00:03 3 3 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
√ All specs passed! 02:43 115 115 - - -
生成的xml结果如图所示
生成Allure报告
执行命令allure serve results
D:\Cypress>allure serve results
Generating report to temp directory...
Report successfully generated to C:\Users\ADMINI~1\AppData\Local\Temp\5521898862344816758\allure-report
Starting web server...
2020-12-28 16:24:21.236:INFO::main: Logging initialized @3690ms to org.eclipse.jetty.util.log.StdErrLog
Server started at . Press to exit
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/116478.html