【问题标题】:Sonar - Xunit file is not parsed by sonar-runner声纳 - 声纳运行器不解析 Xunit 文件
【发布时间】:2015-12-19 08:04:24
【问题描述】:

我在 Python 项目中遇到了一个关于 Sonar-Runner 的奇怪问题。 这是我的conf: SonarQube:5.1.2 声纳亚军:2.4 Python 插件:1.5

我有一个简单的 Python 项目“PyTest”:

  • 测试
  • 报告
  • pgm.py
  • VO.py

我使用nose (v1.3.7) 通过这个命令生成coverage 和xunit 文件:

nostetests --with-coverage --cover-xml --cover-inclusive --with-xunit --xunit-file=reports/xunit.xml --cover-xml-file=reports/cover.xml

我使用“pytestkey”配置 Sonar,这是我的 sonar-project.properties

sonar.projectKey=pytestkey
sonar.projectName=PyTest
sonar.projectVersion=1.0
sonar.sources=.
sonar.tests=tests
sonar.language=py
sonar.exclusions=tests/*

sonar.python.xunit.reportPath=reports/xunit.xml
sonar.python.coverage.reportPath=reports/cover.xml
sonar.python.codeCoveragePlugin=cobertura

当我运行时,一切都找到了,除了 xunit.xml 文件永远不会被解析...

日志:

INFO - Sensor PythonXUnitSensor
DEBUG - Using pattern 'reports/xunit.xml' to find reports
INFO - Sensor PythonXUnitSensor (done) | time 19ms
INFO - Sensor PythonCoverageSensor
DEBUG - Using pattern 'reports/cover.xml' to find reports
INFO - Parsing report '/home/bsantus/workspace/PyTest/reports/cover.xml'
DEBUG - Saving coverage measures for file 'pgm.py'
DEBUG - Saving coverage measures for file 'VO.py'
DEBUG - Parsing integration test coverage reports
DEBUG - Using pattern 'coverage-reports/it-coverage-*.xml' to find reports
DEBUG - Parsing overall test coverage reports
DEBUG - Using pattern 'coverage-reports/overall-coverage-*.xml' to find reports
INFO - Sensor PythonCoverageSensor (done) | time 65ms

知道为什么不使用 xunit.xml 文件吗?

谢谢大家

【问题讨论】:

  • 为什么您认为您的报告没有被使用?您在 SonarQube 中看到了什么?
  • 事实上,我注意到使用了元信息(测试数、成功数、失败数),但它们在 Sonar 中没有可让我浏览测试文件和测试结果的钻取。在阅读了有关 Sonar-runner 的更多信息后,我认为 Sonar 无法将测试结果与源文件相关联。

标签: python report sonarqube nosetests xunit


【解决方案1】:

您的报告已被解析,但 Python 插件 1.5 版的默认行为是仅记录项目级别的指标。 您应该尝试将以下行添加到您的 sonar-project.properties:

sonar.python.xunit.skipDetails=false

【讨论】:

  • 添加此属性后处理报告 '/srv/jenkins/workspace/Platform_Communique_Pull_Requests_Sonar/app/nosetests.xml' 调试:尝试为 'app.test.unit.data_sources.test_mysql 查找 SonarQube 资源。 MysqlTester'... 调试:使用键 'app/test/unit/data_sources/test_mysql/MysqlTester.py' 在 SonarQube 中查找资源 调试:使用键 'app/test/unit/data_sources/test_mysql.py' 到在 SonarQube DEBUG 中查找资源:...找不到“app.test.unit.data_sources.test_mysql.MysqlTester”的资源,无法深入了解此测试的详细信息
猜你喜欢
  • 2018-02-05
  • 2018-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-24
  • 1970-01-01
  • 2013-01-13
相关资源
最近更新 更多