Ich habe ein Django-Projekt, das in einem Maven-Build verpackt ist, die Verpackung und Veröffentlichung behandelt, sowie das Erstellen von Dokumenten und anderen Lebenszyklusaufgaben.Django-Nase Testergebnisse und Abdeckung nicht gesammelt und in Sonar angezeigt
Wir haben Tests, die in Django-Nose ausgeführt werden, die in der Testphase des Maven-Lebenszyklus durchgeführt werden.
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',
]
Diese erfolgreich von maven während der Testphase durchgeführt wird, und gibt ein coverage.xml nosetests.xml die gültigen Inhalte und sind im Zielordner des Build zu enthalten scheint.
[email protected] target cat nosetests.xml
<?xml version="1.0" encoding="UTF-8"?><testsuite name="nosetests" tests="13" errors="2" failures="0" skip="0"><testcase classname="*snip*" name="test_a" time="0.035">
In maven ist die Struktur ein Multi-Modul-POM, in der übergeordneten werden Sonar Variablen konfiguriert.
<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>
Während das Kind enthält die pom, die Pakete, Tests usw.
Beim Laufen mvn saubere Installation, gefolgt von mvn Sonar schafft: Sonar-X, so weit ich das Plugin erkennt sehen die Nasetests und die Coverage-Datei, aber wenn ich Sonar ansehe, kann ich keine Unit-Testergebnisse oder -abdeckung sehen.
[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
So der Quellcode, Komplexität, etc. erscheinen aber weder die Unit-Test-Ergebnisse (auf dem Pfad oben) noch die Abdeckung angezeigt wird.
Versionen:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.0.1</version>
</plugin>
Sonarqube: Version 5.5 Python Plugin: Version 1.5
Edit: Sonarqube auf Version 5.6, Python 1.6-SNAPSHOT Aktualisiert
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
ich verdoppelt überprüft das Arbeitsverzeichnis: [INFO] Basisverzeichnis:/home/user/src/django-app/code [INFO] Workin g Verzeichnis:/home/user/src/django-app/code/ziel/sonar
Ist es auf der Suche nach den Tests und Abdeckung in Bezug auf das Arbeitsverzeichnis?
Ich kompiliert 1.6-SNAPSHOT des Python-Plugins und installiert dies in Sonar, sowie den neuesten Snapshot des Sonar-Maven-Plugin. Es scheint immer noch Pfadprobleme zu geben. – user1640422
Jetzt können die Berichte gefunden werden, aber die Dateipfade in den Berichten können nicht aufgelöst werden. Sie müssen relativ zur Wurzel des Projekts sein. –