我有一个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在测试阶段成功运行的,输出的coverage.xml和nosetests.xml似乎包含有效内容,并且位于构建的目标文件夹中。
user@user 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">在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全新安装时,然后是mvn sonar:sonar -X,据我所见,该插件会检测nosetest和覆盖率文件,但是当查看声纳时,我看不到单元测试结果或覆盖率。
[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
编辑:将SonarQube更新到版本5.6,将python更新到1.6-快照
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我仔细检查了工作目录: INFO Base dir: /home/user/src/django-app/code INFO code dir: /home/user/src/django-app/code/target/sonar
它是否正在查找与工作目录相关的测试和覆盖率?
发布于 2016-07-08 21:56:52
根据您的日志,报告路径似乎是作为绝对路径提供的。版本1.5的python插件只接受相对路径。这是一个将在1.6版本中修复的known limitation。这个新版本几乎已经准备好了,你应该很快就可以测试一个发布候选版本了。这将在SonarQube google group上公布。
发布于 2018-04-11 21:24:38
将sonar.tests属性添加到您的配置:
sonar.tests=tests_folderhttps://stackoverflow.com/questions/38267543
复制相似问题