【问题标题】:Number of unit test using nosetests is not reflecting in sonar report for python codebase使用鼻子测试的单元测试数量未反映在 python 代码库的声纳报告中
【发布时间】:2017-02-24 17:45:41
【问题描述】:

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

我已经使用coverage 和nosetests 插件生成了报告并将其存储到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

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

【问题讨论】:

  • 能够找到解决方案,我需要在 nostests.xml 中附加单元测试文件夹

标签: unit-testing nose coverage.py sonarqube5.6


【解决方案1】:

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

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

【讨论】:

  • 有没有比编辑报告路径更简洁的方法?
  • 谢谢,这对我有用。必须有比编辑nosetests.xml 更好的方法来完成这项工作。但再次感谢!
猜你喜欢
  • 2017-10-25
  • 2014-02-15
  • 2019-10-25
  • 2015-10-06
  • 2016-08-04
  • 2019-11-01
  • 2017-02-11
  • 1970-01-01
  • 2012-10-09
相关资源
最近更新 更多