【问题标题】:Can not add the same measure twice on Python unit test report不能在 Python 单元测试报告上两次添加相同的度量
【发布时间】:2016-04-12 01:20:02
【问题描述】:

升级到以下版本后:

声纳 5.2
Sonar Runner 2.4
Python 插件 1.5

当我在同一个包中有多个测试文件时,我的测试报告没有得到正确处理,例如:

TEST-notas_leitores.tests.NotasLeitoresModelsTest-20160107114942.xml
TEST-notas_leitores.tests.PaginaNotasLeitoresTest-20160107114942.xml

我得到错误:

ERROR: Sonar During Error runner execution
ERROR: Unable to run Sonar
ERROR: Caused by: Can not add the same measure twice on org.sonar.api.resources.File@b497091[key=notas_leitores/tests.py,path=notas_leitores/tests.py,filename=tests.py,language=Python]: org.sonar.api.measures.Measure@27d4561[metricKey=skipped_tests,metric=Metric[id=<null>,key=skipped_tests,description=Number of skipped unit tests, type = INT, direction = -1, domain = Tests, name = Skipped unit tests,qualitative=true,userManaged=false,enabled=true,worstValue=<null>,bestValue=0.0,optimizedBestValue=true,hidden=false,deleteHistoricalData=false],value=0.0,data=<null>,description=<null>,alertStatus=<null>,alertText=<null>,date=<null>,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,requirement=<null>,personId=<null>,persistenceMode=FULL,fromCore=false]

如果这些测试结果被删除,则分析正常进行。

它适用于 Sonar 4.2 和 Python Plugin 1.3。

我的 sonar-project.properties:

sonar.projectKey=key
sonar.projectName=name
sonar.projectVersion=1.0
sonar.sources=module, test
sonar.language=py
sonar.sourceEncoding=UTF-8

sonar.python.coverage.reportPath=coverage.xml
sonar.python.xunit.reportPath=xmlrunner/TEST-*.xml
sonar.dynamicAnalysis=reuseReports
sonar.python.xunit.skipDetails=false
sonar.python.codeCoveragePlugin=cobertura

【问题讨论】:

    标签: python unit-testing sonarqube


    【解决方案1】:

    导入多个测试报告文件有效。但是,它们不应包含相同测试文件的结果(例如失败的测试数)。 notas_leitores/tests.py 就是这种情况。 SonarQube不接受这样的案例:如果结果不同,哪些是正确的?

    如果它与具有相同配置的 SonarQube 4.2 一起使用,我想这个旧版本不会进行相同的检查,因此不会向您显示您的设置存在问题。

    【讨论】:

      猜你喜欢
      • 2014-07-10
      • 2017-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-06
      • 1970-01-01
      • 2017-07-26
      • 1970-01-01
      相关资源
      最近更新 更多