Junit 如何将cucumber特性文件测试添加到XML报告文件
我使用cypress和“cypress junit reporter”将测试结果输出到XML文件。我最近调整了设置以运行cucumber功能文件,但我希望将完整的功能文件文本输出到XML结果文件,而不是当前仅拉入场景。我该怎么做 Cypress.jsonJunit 如何将cucumber特性文件测试添加到XML报告文件,junit,automated-tests,cypress,cypress-cucumber-preprocessor,Junit,Automated Tests,Cypress,Cypress Cucumber Preprocessor,我使用cypress和“cypress junit reporter”将测试结果输出到XML文件。我最近调整了设置以运行cucumber功能文件,但我希望将完整的功能文件文本输出到XML结果文件,而不是当前仅拉入场景。我该怎么做 Cypress.json { "chromeWebSecurity": false, "baseUrl": "https://www.testurl.com", "defaul
{
"chromeWebSecurity": false,
"baseUrl": "https://www.testurl.com",
"defaultCommandTimeout": 10000,
"requestTimeout": 20000,
"experimentalFetchPolyfill": true,
"video": false,
"scrollBehavior": "nearest",
"reporter": "cypress-junit-reporter",
"reporterOptions": {
"mochaFile": "cypress/results/output-[hash].xml",
"jenkinsMode": true,
"useFullSuiteTitle": true,
"testsuitesTitle": true,
"antMode": true
},
"experimentalSourceRewriting": true,
"testFiles": "**/*.{feature,features}"
}
输出XML文件
?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="" timestamp="2021-05-17T13:42:07" tests="0" file="cypress/integration/BDDTest.feature" package="" hostname="undefined" id="0" errors="0" time="0.00" failures="0">
<properties>
</properties>
<system-out>
</system-out>
<system-err>
</system-err>
</testsuite>
<testsuite name="Root Suite.Test scenarios for BDD" timestamp="2021-05-17T13:42:07" tests="1" package="Root Suite.Test scenarios for BDD" hostname="undefined" id="1" errors="0" time="9.05" failures="0">
<properties>
</properties>
<testcase name="User can navigate to Login page" time="9.05" classname="Test scenarios for BDD">
</testcase>
<system-out>
</system-out>
<system-err>
</system-err>
</testsuite>
</testsuites>
在这种情况下,我建议使用Mochawesome Reporter—它是一个定制的Reporter,可生成独立的HTML/CSS/JSON报告,例如: 步骤1:安装 安装摩卡咖啡:
npm安装摩卡——保存开发
安装cypress multi reporters:
npm安装cypress multi Reporter--保存开发人员
安装mochawesome:
npm安装mochawesome--保存开发人员
安装mochawesome合并:
npm安装mochawesome合并--保存开发人员
安装mochawesome报告生成器:
npm安装mochawesome报告生成器--保存开发人员
步骤2:在cypress.json中添加报告器设置,例如:
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"reporterEnabled": "mochawesome",
"mochawesomeReporterOptions": {
"reportDir": "cypress/reports/mocha",
"quite": true,
"overwrite": false,
"html": false,
"json": true
}
}
然后在package.json文件中添加脚本:
"scripts": {
"clean:reports": "rm -R -f cypress/reports && mkdir cypress/reports
&& mkdir cypress/reports/mochareports",
"pretest": "npm run clean:reports",
"scripts": "cypress run",
"combine-reports": "mochawesome-merge
cypress/reports/mocha/*.json > cypress/reports/mochareports/report.json",
"generate-report": "marge cypress/reports/mochareports/
report.json -f report -o cypress/reports/mochareports",
"posttest": "npm run combine-reports && npm run generate-report",
"test" : "npm run scripts || npm run posttest"
}
执行:-npm运行测试
它将自动运行您的测试套件,在“cypress/reports”下创建“mocha”文件夹,并在“mocha”文件夹中创建.json文件
注意:这里是一个很好的视频gid:
PS:欣赏柏树:)
"scripts": {
"clean:reports": "rm -R -f cypress/reports && mkdir cypress/reports
&& mkdir cypress/reports/mochareports",
"pretest": "npm run clean:reports",
"scripts": "cypress run",
"combine-reports": "mochawesome-merge
cypress/reports/mocha/*.json > cypress/reports/mochareports/report.json",
"generate-report": "marge cypress/reports/mochareports/
report.json -f report -o cypress/reports/mochareports",
"posttest": "npm run combine-reports && npm run generate-report",
"test" : "npm run scripts || npm run posttest"
}