Djangonose测试结果和覆盖率未在son中收集和显示

2024-04-24 17:31:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个django项目,它被包装在maven构建中,它处理打包和发布,以及生成文档和其他生命周期任务。在

我们有在django-nose中执行的测试,这些测试在maven生命周期的测试阶段执行。在

NOSE_ARGS = [
  '--with-coverage',
  '--cover-erase',
  '--cover-package={0}'.format(TEST_FOLDERS),
  '--cover-html',
  '--cover-branches',
  '--cover-html-dir=' + COVERAGE_WORK_FOLDER + 'coverage-reports/',
  '--cover-xml',
  '--cover-xml-file=' + COVERAGE_WORK_FOLDER + 'coverage.xml',
  '--with-xunit',
  '--xunit-file=' + COVERAGE_WORK_FOLDER + 'nosetests.xml',
]

这是maven在测试阶段成功运行的,输出覆盖率.xml以及nosetests.xml它似乎包含有效内容,并且位于生成的目标文件夹中。在

^{pr2}$

在maven中,结构是一个多模块pom,在父节点中配置了声纳变量。在

<sonar.language>py</sonar.language>
<sonar.python.xunit.reportPath>${project.build.directory}/nosetests.xml</sonar.python.xunit.reportPath>
<sonar.python.coverage.reportPath>${project.build.directory}/coverage.xml</sonar.python.coverage.reportPath>
<sonar.sources>src/main/python/django</sonar.sources>
<sonar.python.xunit.skipDetails>false</sonar.python.xunit.skipDetails>

而这个孩子包含创建、包、测试等的pom

运行mvn clean install时,然后运行mvn声纳:声纳-X,就我所能看到的插件检测nosetests和覆盖文件,但是当我看到sonar时,我看不到单元测试结果或覆盖率。在

[INFO] Sensor PythonXUnitSensor
[DEBUG] Using pattern '/home/user/src/django-app/code/target/nosetests.xml' to find reports
[INFO] Sensor PythonXUnitSensor (done) | time=3492ms
[INFO] Sensor PythonCoverageSensor
[DEBUG] Using pattern '/home/user/src/django-app/code/target/coverage.xml' to find reports
[DEBUG] Parsing coverage reports
[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=1321ms
**SNIP**
[INFO] CPD calculation finished
[INFO] Analysis report generated in 542ms, dir size=756 KB
[INFO] Analysis reports compressed in 879ms, zip size=331 KB
[DEBUG] Upload report
[DEBUG] POST 200 https://sonar.local/api/ce/submit?projectKey=com.example:django&projectName=DJANGO | time=104ms
[INFO] Analysis report uploaded in 106ms
[INFO] ANALYSIS SUCCESSFUL, you can browse https://sonar.local/dashboard/index/com.example:django
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at https://sonar.local/api/ce/task?id=AVXFLPhlOl8UXdQaHPyt
[DEBUG] Report metadata written to /home/user/src/django-app/target/sonar/report-task.txt
[DEBUG] Post-jobs : 
[INFO] Analysis report generated in /home/user/src/django-app/target/sonar/batch-report

因此,源代码、复杂性等都会出现,但单元测试结果(在上面的路径中)或覆盖率都不会显示。在

版本:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>sonar-maven-plugin</artifactId>
  <version>3.0.1</version>
</plugin>

SonarQube:5.5版 Python插件:版本1.5

编辑:将SonaQube更新到5.6版本,将python更新到1.6-SNAPSHOT

mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.1-SNAPSHOT:sonar -X -o
---
[DEBUG] Using pattern '/home/user/src/django-app/code/target/nosetests.xml' to find reports
[INFO] Processing report '/home/user/src/django-app/code/target/nosetests.xml'
[DEBUG] Trying to find a SonarQube resource for 'maven.tests.TestMavenVersionsViewSet'
[DEBUG] Using the key 'maven/tests/TestMavenVersionsViewSet.py' to lookup the resource in SonarQube
[DEBUG] Using the key 'maven/tests.py' to lookup the resource in SonarQube
[WARNING] The resource for 'maven.tests.TestMavenVersionsViewSet' is not found, drilling down to the details of this test won't be possible
[DEBUG] Trying to find a SonarQube resource for 'audit.tests.TestSortDeploys'
[DEBUG] Using the key 'audit/tests/TestSortDeploys.py' to lookup the resource in SonarQube
[DEBUG] Using the key 'audit/tests.py' to lookup the resource in SonarQube
[WARNING] The resource for 'audit.tests.TestSortDeploys' is not found, drilling down to the details of this test won't be possible
[INFO] Sensor PythonXUnitSensor (done) | time=4195ms
[INFO] Sensor SCM Sensor (wrapped)
[INFO] SCM provider for this project is: svn
[INFO] 1 files to be analyzed
[DEBUG] Working directory: /home/user/src/django-app/code
[DEBUG] Annotate file src/main/python/audit_ws/audit/tests.py
[DEBUG] File [moduleKey=internal.build.services:audit_ws-site, relative=src/main/python/audit_ws/audit/tests.py, basedir=/home/user/src/django-app/code] is not versionned or contains local modifications. Skipping it.
[INFO] 0/1 files analyzed
[WARNING] Missing blame information for the following files:
[WARNING]   * /home/user/src/django-app/code/src/main/python/audit_ws/audit/tests.py
[WARNING] This may lead to missing/broken features in SonarQube
[INFO] Sensor SCM Sensor (wrapped) (done) | time=1521ms
[INFO] Sensor Python Squid Sensor (wrapped)
[DEBUG] Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
*SNIP*
[INFO] Python unit test coverage
[DEBUG] Using pattern '/home/user/src/django-app/code/target/coverage.xml' to find reports
[INFO] Parsing report '/home/user/src/django-app/code/target/coverage.xml'
[DEBUG] Cannot find the file 'lib/JiraSoap.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/admin.py', ignoring coverage measures
[DEBUG] Cannot find the file 'config_item/autocomplete_light_registry.py', ignoring coverage measures
[DEBUG] Cannot find the file 'config_item/forms.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/models.py', ignoring coverage measures
[DEBUG] Cannot find the file 'lib/productws.py', ignoring coverage measures
[DEBUG] Cannot find the file 'lib/renderers.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard/serializers.py', ignoring coverage measures
[DEBUG] Cannot find the file 'audit_ws/settings.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/tasks.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/urls.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/views.py', ignoring coverage measures
[DEBUG] Cannot find the file 'audit/management.py', ignoring coverage measures
[DEBUG] Cannot find the file 'audit/management/commands.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/templatetags.py', ignoring coverage measures
[INFO] Python integration test coverage
[DEBUG] Using pattern 'coverage-reports/it-coverage-*.xml' to find reports
[DEBUG] No report was found for sonar.python.coverage.itReportPath using default pattern coverage-reports/it-coverage-*.xml
[INFO] Python overall test coverage
[DEBUG] Using pattern 'coverage-reports/overall-coverage-*.xml' to find reports
[DEBUG] No report was found for sonar.python.coverage.overallReportPath using default pattern coverage-reports/overall-coverage-*.xml
[INFO] Sensor Python Squid Sensor (wrapped) (done) | time=3057ms
[INFO] Sensor XmlFileSensor (wrapped)
[INFO] Sensor XmlFileSensor (wrapped) (done) | time=0ms
[INFO] Sensor Zero Coverage Sensor (wrapped)
[INFO] Sensor Zero Coverage Sensor (wrapped) (done) | time=82ms
[INFO] Sensor Code Colorizer Sensor (wrapped)
[INFO] Sensor Code Colorizer Sensor (wrapped) (done) | time=3ms
[INFO] Sensor CPD Block Indexer (wrapped)
[INFO] DefaultCpdBlockIndexer is used for py
[DEBUG] Using pattern '/home/user/src/django-app/code/target/nosetests.xml' to find reports
[INFO] Processing report '/home/user/src/django-app/code/target/nosetests.xml'
[DEBUG] Trying to find a SonarQube resource for 'maven.tests.TestMavenVersionsViewSet'
[DEBUG] Using the key 'maven/tests/TestMavenVersionsViewSet.py' to lookup the resource in SonarQube
[DEBUG] Using the key 'maven/tests.py' to lookup the resource in SonarQube
[WARNING] The resource for 'maven.tests.TestMavenVersionsViewSet' is not found, drilling down to the details of this test won't be possible
[DEBUG] Trying to find a SonarQube resource for 'audit.tests.TestSortDeploys'
[DEBUG] Using the key 'audit/tests/TestSortDeploys.py' to lookup the resource in SonarQube
[DEBUG] Using the key 'audit/tests.py' to lookup the resource in SonarQube
[WARNING] The resource for 'audit.tests.TestSortDeploys' is not found, drilling down to the details of this test won't be possible
[INFO] Sensor PythonXUnitSensor (done) | time=4195ms
[INFO] Sensor SCM Sensor (wrapped)
[INFO] SCM provider for this project is: svn
[INFO] 1 files to be analyzed
[DEBUG] Working directory: /home/user/src/django-app/code
[DEBUG] Annotate file src/main/python/audit_ws/audit/tests.py
[DEBUG] File [moduleKey=internal.build.services:audit_ws-site, relative=src/main/python/audit_ws/audit/tests.py, basedir=/home/user/src/django-app/code] is not versionned or contains local modifications. Skipping it.
[INFO] 0/1 files analyzed
[WARNING] Missing blame information for the following files:
[WARNING]   * /home/user/src/django-app/code/src/main/python/audit_ws/audit/tests.py
[WARNING] This may lead to missing/broken features in SonarQube
[INFO] Sensor SCM Sensor (wrapped) (done) | time=1521ms
[INFO] Sensor Python Squid Sensor (wrapped)
[DEBUG] Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
*SNIP*
[INFO] Python unit test coverage
[DEBUG] Using pattern '/home/user/src/django-app/code/target/coverage.xml' to find reports
[INFO] Parsing report '/home/user/src/django-app/code/target/coverage.xml'
[DEBUG] Cannot find the file 'lib/JiraSoap.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/admin.py', ignoring coverage measures
[DEBUG] Cannot find the file 'config_item/autocomplete_light_registry.py', ignoring coverage measures
[DEBUG] Cannot find the file 'config_item/forms.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/models.py', ignoring coverage measures
[DEBUG] Cannot find the file 'lib/productws.py', ignoring coverage measures
[DEBUG] Cannot find the file 'lib/renderers.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard/serializers.py', ignoring coverage measures
[DEBUG] Cannot find the file 'audit_ws/settings.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/tasks.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/urls.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/views.py', ignoring coverage measures
[DEBUG] Cannot find the file 'audit/management.py', ignoring coverage measures
[DEBUG] Cannot find the file 'audit/management/commands.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/templatetags.py', ignoring coverage measures
[INFO] Python integration test coverage
[DEBUG] Using pattern 'coverage-reports/it-coverage-*.xml' to find reports
[DEBUG] No report was found for sonar.python.coverage.itReportPath using default pattern coverage-reports/it-coverage-*.xml
[INFO] Python overall test coverage
[DEBUG] Using pattern 'coverage-reports/overall-coverage-*.xml' to find reports
[DEBUG] No report was found for sonar.python.coverage.overallReportPath using default pattern coverage-reports/overall-coverage-*.xml
[INFO] Sensor Python Squid Sensor (wrapped) (done) | time=3057ms
[INFO] Sensor XmlFileSensor (wrapped)
[INFO] Sensor XmlFileSensor (wrapped) (done) | time=0ms
[INFO] Sensor Zero Coverage Sensor (wrapped)
[INFO] Sensor Zero Coverage Sensor (wrapped) (done) | time=82ms
[INFO] Sensor Code Colorizer Sensor (wrapped)
[INFO] Sensor Code Colorizer Sensor (wrapped) (done) | time=3ms
[INFO] Sensor CPD Block Indexer (wrapped)
[INFO] DefaultCpdBlockIndexer is used for py
[DEBUG] Using pattern '/home/user/src/django-app/code/target/nosetests.xml' to find reports
[INFO] Processing report '/home/user/src/django-app/code/target/nosetests.xml'
[DEBUG] Trying to find a SonarQube resource for 'maven.tests.TestMavenVersionsViewSet'
[DEBUG] Using the key 'maven/tests/TestMavenVersionsViewSet.py' to lookup the resource in SonarQube
[DEBUG] Using the key 'maven/tests.py' to lookup the resource in SonarQube
[WARNING] The resource for 'maven.tests.TestMavenVersionsViewSet' is not found, drilling down to the details of this test won't be possible
[DEBUG] Trying to find a SonarQube resource for 'audit.tests.TestSortDeploys'
[DEBUG] Using the key 'audit/tests/TestSortDeploys.py' to lookup the resource in SonarQube
[DEBUG] Using the key 'audit/tests.py' to lookup the resource in SonarQube
[WARNING] The resource for 'audit.tests.TestSortDeploys' is not found, drilling down to the details of this test won't be possible
[INFO] Sensor PythonXUnitSensor (done) | time=4195ms
[INFO] Sensor SCM Sensor (wrapped)
[INFO] SCM provider for this project is: svn
[INFO] 1 files to be analyzed
[DEBUG] Working directory: /home/user/src/django-app/code
[DEBUG] Annotate file src/main/python/audit_ws/audit/tests.py
[DEBUG] File [moduleKey=internal.build.services:audit_ws-site, relative=src/main/python/audit_ws/audit/tests.py, basedir=/home/user/src/django-app/code] is not versionned or contains local modifications. Skipping it.
[INFO] 0/1 files analyzed
[WARNING] Missing blame information for the following files:
[WARNING]   * /home/user/src/django-app/code/src/main/python/audit_ws/audit/tests.py
[WARNING] This may lead to missing/broken features in SonarQube
[INFO] Sensor SCM Sensor (wrapped) (done) | time=1521ms
[INFO] Sensor Python Squid Sensor (wrapped)
[DEBUG] Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
*SNIP*
[INFO] Python unit test coverage
[DEBUG] Using pattern '/home/user/src/django-app/code/target/coverage.xml' to find reports
[INFO] Parsing report '/home/user/src/django-app/code/target/coverage.xml'
[DEBUG] Cannot find the file 'lib/JiraSoap.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/admin.py', ignoring coverage measures
[DEBUG] Cannot find the file 'config_item/autocomplete_light_registry.py', ignoring coverage measures
[DEBUG] Cannot find the file 'config_item/forms.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/models.py', ignoring coverage measures
[DEBUG] Cannot find the file 'lib/productws.py', ignoring coverage measures
[DEBUG] Cannot find the file 'lib/renderers.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard/serializers.py', ignoring coverage measures
[DEBUG] Cannot find the file 'audit_ws/settings.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/tasks.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/urls.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/views.py', ignoring coverage measures
[DEBUG] Cannot find the file 'audit/management.py', ignoring coverage measures
[DEBUG] Cannot find the file 'audit/management/commands.py', ignoring coverage measures
[DEBUG] Cannot find the file 'wallboard_ws/templatetags.py', ignoring coverage measures
[INFO] Python integration test coverage
[DEBUG] Using pattern 'coverage-reports/it-coverage-*.xml' to find reports
[DEBUG] No report was found for sonar.python.coverage.itReportPath using default pattern coverage-reports/it-coverage-*.xml
[INFO] Python overall test coverage
[DEBUG] Using pattern 'coverage-reports/overall-coverage-*.xml' to find reports
[DEBUG] No report was found for sonar.python.coverage.overallReportPath using default pattern coverage-reports/overall-coverage-*.xml
[INFO] Sensor Python Squid Sensor (wrapped) (done) | time=3057ms
[INFO] Sensor XmlFileSensor (wrapped)
[INFO] Sensor XmlFileSensor (wrapped) (done) | time=0ms
[INFO] Sensor Zero Coverage Sensor (wrapped)
[INFO] Sensor Zero Coverage Sensor (wrapped) (done) | time=82ms
[INFO] Sensor Code Colorizer Sensor (wrapped)
[INFO] Sensor Code Colorizer Sensor (wrapped) (done) | time=3ms
[INFO] Sensor CPD Block Indexer (wrapped)
[INFO] DefaultCpdBlockIndexer is used for py

我已经仔细检查了工作目录: [信息]基本目录:/home/user/src/django app/code [信息]工作方向:/home/user/src/django app/code/target/sonar

它是否在寻找与工作目录相关的测试和覆盖范围?在


Tags: thetopydebuginfosrccoverageaudit
2条回答

根据您的日志,报告路径似乎是作为绝对路径提供的。 版本1.5的python插件只接受相对路径。 这是一个known limitation,它将在1.6版本中修复。这个新版本已经准备好了,您应该能够很快测试一个候选版本。这将在SonarQube google group上公布。在

sonar.tests属性添加到配置中:

sonar.tests=tests_folder

相关问题 更多 >