Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当测试失败时,cypress mocha junit reporter会生成空的junit xml文件_Junit_Cypress - Fatal编程技术网

当测试失败时,cypress mocha junit reporter会生成空的junit xml文件

当测试失败时,cypress mocha junit reporter会生成空的junit xml文件,junit,cypress,Junit,Cypress,有人能帮我找出为什么在junit输出xml文件中看不到测试结果吗 My cypress.json文件的配置如下: "reporter": "mocha-junit-reporter", "reporterOptions": { "testsuitesTitle": true, "mochaFile": "./cypress/reports/junit.xml&

有人能帮我找出为什么在junit输出xml文件中看不到测试结果吗

My cypress.json文件的配置如下:

  "reporter": "mocha-junit-reporter",
  "reporterOptions": {
     "testsuitesTitle": true,
     "mochaFile": "./cypress/reports/junit.xml"
  }
我是这样运行的:

start-server-and-test start-dev-env http://localhost:4200 cy:run
其中,start dev env的定义如下:

"start-dev-env": "ng serve --proxy-config proxy/dev${ENV_SPECIFIER}.json --live-reload=false",
如果测试失败,我会得到如下junit输出:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="0.0000" tests="0" failures="0">
</testsuites>

问题在于,除非在文件名中添加哈希,否则后续测试套件会覆盖早期测试套件,从而导致信息丢失

因此,cypress.json应该如下所示

  "reporter": "mocha-junit-reporter",
 "reporterOptions": {
    "testsuitesTitle": true,
    "mochaFile": "./cypress/reports/junit.[hash].xml"
 }

散列将替换为日期时间散列,然后您将有一组测试xml文件要处理。

如果您想合并所有这些多个
junit.[hash].xml
创建为单个
mergedreport.xml
报告,只需添加到上面的答案中,然后,您可以使用此软件包,该软件包用于在CI管道上运行它,CI管道通常使用以下命令查找单个报告器:

jrm./cypress/reports/mergedreport.xml.“/cypress/reports/junit*.xml”