简体   繁体   English

有没有办法在 Angular-Jest 项目的 Sonarqube 报告中覆盖单元测试的数量?

[英]Is there a way to bring number of unit tests under coverage in Sonarqube report for Angular-Jest project?

I have run sonar for Angular-Jest project and got the unit test coverage but am not getting number of unit tests.我已经为 Angular-Jest 项目运行声纳并获得了单元测试覆盖率,但没有获得单元测试的数量。

My Sonar properties,(sonarqube version - 7.7)我的声纳属性,(声纳版本 - 7.7)

sonar.host.url=http://localhost:9000
sonar.login=admin
sonar.password=admin
sonar.projectKey=my-app
sonar.projectName=my-app
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.exclusions=**/node_modules/**
sonar.tests=src
sonar.test.inclusions=**/*.spec.ts
sonar.typescript.lcov.reportPaths=coverage/my-app/lcov.info
sonar.scm.disabled=true
sonar.path.temp=C:\Sonar\sonarqube-7.7\temp

在此处输入图像描述

Is there any way to bring number of unit tests under coverage heading?有什么方法可以将单元测试的数量置于覆盖标题下?

Thanks in advance!提前致谢!

After many trial and error, finally got the no.of unit tests in sonar report.经过多次尝试和错误,终于得到了声纳报告中单元测试的数量。

Added sonar-scanner using the below command,使用以下命令添加声纳扫描仪,

npm install sonar-scanner --save-dev

Then in package.json file add the following lines in scripts,然后在 package.json 文件中,在脚本中添加以下行,

"scripts": {
    "sonar": "sonar-scanner",
    "sonar-scanner": "node_modules/sonar-scanner/bin/sonar-scanner.bat"
  }

In sonar-project.properties file, add the below line在 sonar-project.properties 文件中,添加以下行

sonar.testExecutionReportPaths=test-report.xml

Finally run sonar using StartSonar.bat and run最后使用StartSonar.bat运行声纳并运行

npm run sonar

And when we run https:localhost:9000/projects, we can find no.of unit tests under coverage part.当我们运行 https:localhost:9000/projects 时,我们可以在 coverage 部分找到 no.of unit tests。

在此处输入图像描述

Reference links : https://medium.com/@learning.bikash/angular-code-coverage-with-sonarqube-d2283442080b参考链接https://medium.com/@learning.bikash/angular-code-coverage-with-sonarqube-d2283442080b

https://medium.com/beingcoders/setup-sonarqube-with-angular-project-in-6-minutes-57a87b3ca8c4 https://medium.com/beingcoders/setup-sonarqube-with-angular-project-in-6-minutes-57a87b3ca8c4

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

相关问题 SonarQube为什么不在我的lcov报告中计算文件的覆盖率? (角度项目) - Why is SonarQube calculating coverage for files not in my lcov report? (Angular project) Angular 6 - Sonarqube 覆盖率报告始终为 0 但 karma 显示覆盖率 - Angular 6 - Sonarqube coverage report is always 0 but karma shows coverage 将Angular单元测试报告导入Sonarqube - Import Angular unit test report into Sonarqube Angular 12 / 13:无法将代码覆盖率报告与 sonarqube 集成 - Angular 12 / 13 : Not able to integrate code coverage report with sonarqube Jest单元测试中的Angular Circular Dependency问题 - Angular Circular Dependency issue in Jest unit tests 如何为一个Angular项目“在sonarqube中启用前端代码覆盖” - How to “Enable front-end code coverage in sonarqube” for a Angular project 如何在玩笑进行单元测试时模拟 angular 中的 ResizeObserver polyfill? - How to mock ResizeObserver polyfill in angular, when doing unit tests with jest? 有没有办法分批处理Karma - Angular单元测试? - Is there a way to process Karma - Angular unit tests in batches? SonarQube 在 angular 项目中 - 报告的第 2 行引用了未知语言的文件 - SonarQube in angular project - Line 2 of report refers to a file with an unknown language 玩笑 + 角度 + 单元测试 - Jest + angular +unit test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM