Sonarqube API 单类测试覆盖率 [英] Sonarqube API single class test coverage

查看:84
本文介绍了Sonarqube API 单类测试覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 SonarQube API(Sonar 版本 4.1.2)检索单个类的单元测试代码覆盖率.一切正常,当我直接转到声纳仪表板并转到课程的覆盖率选项卡时,我可以看到指标正常:

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)

谁能告诉我通过声纳 API 接口检索相同/相似信息的正确调用吗?我已经看过 http://docs.sonarqube.org/上的文档display/SONAR/Metric+definitions 并且可以在项目级别获取测试覆盖率指标,但我看不到如何为单个类构建查询.

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.

推荐答案

我认为这就是你所追求的

I think this is what you are after

[hostname]/api/resources?resource=[com.test]:[module-name]:[完全限定类]&metrics=coverage,branch_coverage

[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

这篇关于Sonarqube API 单类测试覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆