适用于 python 的 Sonarqube:未发现测试成功分数 - 找不到 'tests.test_transformation_helper.TestCase' 的资源



我正在使用Sonarqube在Jenkins的作业中扫描我的Python代码。要使我的构建"通过"(即公司内部规则),声纳扫描必须具有测试覆盖率和测试成功得分。我正在使用鼻子和覆盖范围来运行我的测试并生成这些报告(nosetests.xml和coverage.xml):

nosetests --with-coverage --cover-erase --with-xunit --exe --cover-package=at_overlay
coverage report --omit src/tests/*,*/__init__.py
coverage xml --omit src/tests/*,*/__init__.py

我的扫描报告具有正确的覆盖范围数字,但没有测试成功得分。当我查看输出时,我会在扫描过程中获得以下内容:

14:47:19 [sonarQube scan] 14:47:19.252 INFO  - Processing report '/usr/src/app/jenkins/workspace/at-overlay_release_uat-BNAIZGRBYSDANHOQHN2L6FCL4JRFHKJO5WZOZYKP6RAZFUAILPPA/nosetests.xml'
14:47:19 [sonarQube scan] 14:47:19.256 WARN  - The resource for 'tests.test_transformation_helper.TestCase' is not found, drilling down to the details of this test won't be possible
14:47:19 [sonarQube scan] 14:47:19.256 WARN  - The resource for 'tests.test_data_wrapper.TestDataWrapper' is not found, drilling down to the details of this test won't be possible

我在此处找到了一个答案 - 将Python测试的信息导入Sonarqube,尽管当我尝试时,我仍然得到相同的结果。我在这里缺少明显的东西吗?

尝试删除测试的省略:

coverage report --omit src/tests/*,*/__init__.py
coverage xml --omit src/tests/*,*/__init__.py 

to

coverage report --omit */__init__.py
coverage xml --omit */__init__.py

声纳使用测试文件来计算测试成功,如OSS插件代码所示

那是警告日志来自的地方。

相关内容

最新更新