Sonar Python覆盖报告问题

时间:2013-09-20 18:11:54

标签: python sonarqube

Sonar无法显示Cobertura生成的Python模块的代码覆盖率。我目前正在使用Jenkins进行构建并与Sonar集成。我的声纳属性是:

# Info required for Sonar
sonar.sources=module
sonar.language=py

# Additional Configuration
sonar.python.xunit.reportPath=**/nosetests.xml
sonar.python.coverage.reportPath=**/coverage.xml

并且控制台输出显示:

12:03:26.458 INFO  - Sensor PythonXunitSensor...
12:03:27.305 INFO  - Processing report 'nosetests.xml'
12:03:27.305 INFO  - Parsing report 'nosetests.xml'
12:03:27.460 INFO  - Sensor PythonXunitSensor done: 1002 ms
12:03:27.460 INFO  - Sensor PythonCoverageSensor...
12:03:28.216 INFO  - Parsing report 'coverage.xml'
12:03:28.269 INFO  - Sensor PythonCoverageSensor done: 809 ms
12:03:28.269 INFO  - Sensor CpdSensor...
12:03:28.270 INFO  - SonarBridgeEngine is used
12:03:28.426 INFO  - Cross-project analysis disabled
12:03:29.181 INFO  - Sensor CpdSensor done: 912 ms

但是在Sonar中我只看到了单元测试结果,但没有看到覆盖数据,当我运行调试选项时,它说:

16:51:23.124 DEBUG - Cannot find the file , ignoring coverage measures
16:51:23.125 DEBUG - Cannot find the file , ignoring coverage measures
16:51:23.125 DEBUG - Cannot find the file , ignoring coverage measures
16:51:23.126 DEBUG - Cannot find the file , ignoring coverage measures
16:51:23.126 DEBUG - Cannot find the file , ignoring coverage measures

我也检查了案例和路径,但没有发现问题。任何人都可以帮助我吗?

2 个答案:

答案 0 :(得分:2)

我遇到了类似的问题。 coverage.xml文件中的路径错误,我只是运行一个sed命令来替换所有文件路径以添加模块目录。

答案 1 :(得分:-1)

尝试将sonar.python.coveragePlugin=cobertura添加到您的声纳属性并再次运行。