1

我正在尝试将测试覆盖率报告和单元测试详细信息(测试用例的数量,通过的测试用例的数量)放入声纳。

我使用覆盖率和鼻子测试插件生成报告并将其存储到coverage.xml 和nosetests.xml

我的 sonar.properties 文件看起来像

sonar.projectKey=python
sonar.projectName=Python
sonar.projectVersion=1.0
sonar.sources=vmturbo
sonar.tests=tests
sonar.language=py
sonar.sourceEncoding=UTF-8
sonar.python.xunit.reportPath=nosetests.xml
sonar.python.coverage.reportPath=coverage.xml

在运行 sonar-runner 时,我在日志中收到以下消息

0:29:51.022 INFO  - Processing report '/Users/deepeshjain/Development/Python/CD/python-distribution/nosetests.xml'
00:29:51.027 WARN  - The resource for 'vmturbo_unit_tests.Test' is not found, drilling down to the details of this test won't be possible
00:29:51.027 INFO  - Sensor PythonXUnitSensor (done) | time=115ms
00:29:51.027 INFO  - Sensor SCM Sensor
00:29:51.050 INFO  - Sensor SCM Sensor (done) | time=23ms
00:29:51.051 INFO  - Sensor Python Squid Sensor
00:29:51.221 INFO  - Python unit test coverage
00:29:51.223 INFO  - Parsing report '/Users/deepeshjain/Development/Python/CD/python-distribution/coverage.xml'
00:29:51.229 INFO  - Python integration test coverage
00:29:51.232 INFO  - Python overall test coverage
00:29:51.234 INFO  - Sensor Python Squid Sensor (done) | time=183ms

我能够获得关于声纳的测试覆盖率报告,但无法获得相同的单元测试用例的数量。

4

1 回答 1

4

在尝试了多个选项后,将测试用例路径添加到 nosetests.xml 对我有用。

sed -i 's/classname="/classname="tests./g' nosetests.xml

于 2017-02-24T09:45:41.847 回答