SonarQube单元测试报告不显示Javascript文件

时间:2018-05-29 13:00:23

标签: javascript sonarqube sonarqube-scan

我有一个包含Java和Javascript模块的maven项目。 我没有在SonarQube的测试报告中看到Javascript单元测试文件,只看到了Java单元测试文件。     coverage_reports

coverage_reports文件夹中,我有Jest创建的cobertura-coverage.xml。 此sonar.javascript.jstest.reportPaths是否仍在使用,或者是否被其他配置替换。我们在服务器上使用Sonarqube 6.7。

编辑: 对于其他人来说,我使用jest-sonar-reporter和测试脚本作为

"test": "cross-env CI=true NODE_PATH=./src react-scripts test --env=jsdom --coverage --no-cache -u --testResultsProcessor jest-sonar-reporter"

这创建了一个我用过的测试报告xml文件

<sonar.tests>src/test</sonar.tests>
<sonar.testExecutionReportPaths>path/to/test-report.xml</sonar.testExecutionReportPaths>
<sonar.javascript.lcov.reportPaths>path/to/lcov.info</sonar.javascript.lcov.reportPaths>

1 个答案:

答案 0 :(得分:1)

据我所知,sonar.javascript.jstest.reportPaths不存在(从未做过)。

有两件事(问题我不确定你需要哪一件):

  1. 单元测试报告导入(多少单元测试,失败,跳过等)。为此,请参阅文档here(您最终需要使用sonar.testExecutionReportPaths属性。)
  2. 覆盖率报告导入。如果您能够生成LCOV,请参阅文档here。如果没有,您需要以通用SonarQube格式转换报告(请参阅here)。
  3. 最后,要查看JS的单元测试文件,请正确设置sonar.tests属性(由于足够智能的maven扫描程序而显示Java测试文件)