Mat*_* B. 8 unit-testing sonarqube jestjs
我一直在尝试找出如何用Jest单元测试和.net单元测试填充SonarQube。
我有SQ 6.7的本地版本以及Javascript和C#插件的所有最新版本。
关于Jest,我有声纳的Jest记者来导出test-report.xml文件,并且还生成了lcov.info文件。
SonarQube能够读取lcov,并且看到覆盖率%,但是无论我设置为包含/排除还是测试路径,它都不会显示与源文件关联的测试。
文件结构为所有.js,而.test.js与每个模块位于同一目录中。
为我指明正确方向的任何帮助,或者遇到或克服此问题的其他人,将不胜感激。
Swa*_*osh 13
看来我已经找到了使其工作的方法。诀窍在于同时拥有sonar.sources并sonar.tests指向同一个目录(因为我们在同一个目录下两个测试和源),然后使用sonar.tests.inclusions模式匹配测试文件用.test.js或.spec.js扩展。
这是一个sonar-project.properties假定以下条件的示例:
src/components/Foo/Foo.jsx 主要组成部分。src/components/Foo/Foo.spec.jsx 测试文件。# Source
sonar.sources=src
# Where to find tests file, also src
sonar.tests=src
# But we get specific here
# We don't need to exclude it in sonar.sources because it is automatically taken care of
sonar.test.inclusions=src/**/*.spec.js,src/**/*.spec.jsx,src/**/*.test.js,src/**/*.test.jsx
# Now specify path of lcov and testlog
sonar.javascript.lcov.reportPaths=coverage/jest/lcov.info
sonar.testExecutionReportPaths=coverage/jest/testlog.xml
Run Code Online (Sandbox Code Playgroud)
现在,您的测试文件也会显示出来。
更多信息在这里https://github.com/3dmind/jest-sonar-reporter/issues/23