我将 Cypress 与 JUnit Reporter 结合使用,自动化套件在 Jenkin 中运行。但在Jenkin的Junit测试结果中,包名始终显示为root。
如何将其从 root 更改为任何其他名称?
下面是我的 cypress.json 记者选项配置。
"reporter": "cypress-junit",
"reporterOptions": {
"testCaseSwitchClassnameAndName": true,
"rootSuiteTitle":"MYPROJECT-UI",
"testsuitesTitle": "MYPROJECT-UI-TEST",
"suiteTitleSeparatedBy": ".",
"useFullSuiteTitle":true,
"mochaFile": "cypress/reports/myproject-ui-report[hash].xml",
"toConsole": false,
"outputs": true,
"jenkinsMode":true
```
XML File generated post execution of Test Suite:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="MYPROJECT-UI-TEST" time="25.085" tests="2" failures="0">
<testsuite name="" timestamp="2020-04-28T14:12:06" tests="0" file="cypress\integration\001_Login_spec.js" failures="0" time="0">
</testsuite>
<testsuite name="MYPROJECT-UI.Verify SKLM Login functionlity" timestamp="2020-04-28T14:12:06" tests="2" failures="0" time="25.085">
<testcase name="Invalid username and password" time="3.707" classname="Login Test">
</testcase>
<testcase name="Valid username and password" time="21.378" classname="Login Test">
</testcase>
</testsuite>
</testsuites>
也许有点晚了,但我想我刚刚找到了这个问题的答案。
您还可以通过设置reporterOptions.testsuitesTitle来配置testsuites.name属性,并通过设置reporterOptions.rootSuiteTitle来配置根套件的名称属性
https://github.com/michaelleeallen/mocha-junit-reporter
部分:结果报告编辑: cypress.json 文件中的用法示例:
{
"reporter": "junit",
"reporterOptions": {
"mochaFile": "results/my-test-output.xml",
"toConsole": true
}
}
尚未测试。