简体   繁体   English

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

[英]SonarQube unit test report doesnt show Javascript files

I have a maven project with modules in both Java and Javascript. 我有一个带有Java和Javascript模块的Maven项目。 I am not seeing the Javascript unit test files in test report in SonarQube but only Java unit test files. 我在SonarQube的测试报告中没有看到Javascript单元测试文件,但是只有Java单元测试文件。 coverage_reports coverage_reports

In coverage_reports folder I have cobertura-coverage.xml created by Jest. coverage_reports文件夹中,我有Jest创建的cobertura-coverage.xml Is this sonar.javascript.jstest.reportPaths still used or has it been replaced by some other configuration. 这个sonar.javascript.jstest.reportPaths是否仍在使用或已被其他配置替代。 We are using Sonarqube 6.7 at our server. 我们在服务器上使用Sonarqube 6.7。

Edit: For others to know, I used jest-sonar-reporter and test script as 编辑:为了让其他人知道,我使用了jest-sonar-reporter和测试脚本作为

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

This created a test report xml file that I used like this 这创建了一个我像这样使用的测试报告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>

As far as I can say sonar.javascript.jstest.reportPaths doesn't exist (and never did). 据我sonar.javascript.jstest.reportPaths不存在(也从未存在)。

There are 2 things (from question I'm not sure which one you need): 有两件事(从问题上我不确定您需要哪一件事):

  1. Unit test report import (how many unit tests, which failed, which skipped etc). 导入单元测试报告(多少单元测试,哪些失败,哪些跳过等)。 For that, see doc here (you will need to use sonar.testExecutionReportPaths property eventually). 为此,请参阅此处的文档(最终将需要使用sonar.testExecutionReportPaths属性)。
  2. Coverage report import. 覆盖率报告导入。 If you are able to produce LCOV see doc here . 如果您能够产生LCOV,请参阅此处的文档。 If not, you will need to convert your report in generic SonarQube format (see here ). 否则,您将需要将报告转换为通用的SonarQube格式(请参阅此处 )。

Finally, to see unit test files for JS, set correctly sonar.tests property (Java test files are displayed due to smart enough maven scanner) 最后,要查看JS的单元测试文件,请正确设置sonar.tests属性(由于足够聪明的maven扫描器,因此显示了Java测试文件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM