Sonarqube API single class test coverage

▼魔方 西西 提交于 2019-12-01 07:14:24

问题


I am trying to retrieve the unit test code coverage for individual classes through the SonarQube API (Sonar version 4.1.2). Everything is working fine, and I can see the metrics okay when I go directly to the sonar dashboard and go to the coverage tab for a class:

    93.9%   by unit tests Line coverage: 97.9% (285/291) Branch coverage: 85.0% (113/133)

Can anyone tell me the correct call to retrieve this same/similar information through the sonar API interface please? I've already had a look at the documentation at http://docs.sonarqube.org/display/SONAR/Metric+definitions and can get test coverage metrics back at project level but I can't see how to construct a query for individual classes.


回答1:


I think this is what you are after

[hostname]/api/resources?resource=[com.test]:[module-name]:[fully qualified class]&metrics=coverage,branch_coverage

I have added an example below.

http://sonar-server/api/resources?resource=com.test:module:com.test.service.impl.CheckServiceImpl&metrics=coverage,branch_coverage

I looked at the page you shared and used this also :

http://docs.codehaus.org/pages/viewpage.action?pageId=229743280



来源:https://stackoverflow.com/questions/27959322/sonarqube-api-single-class-test-coverage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!