【问题标题】:Sonarqube test report "report refers to a file which is not configured as a test file" when tests and source are together当测试和源在一起时,Sonarqube 测试报告“报告指的是未配置为测试文件的文件”
【发布时间】:2019-12-19 08:08:10
【问题描述】:

我正在使用 TypeScript 和 Jest,并将我的测试放在我的源文件旁边。例如:

  • 一些目录
    • someCode.ts
    • someCode.spec.ts

当我尝试导入 text-report.xml(看起来很好并且与格式匹配)时,我收到一条错误消息:

'第 X 行报告引用了一个未配置为测试文件的文件:/someDir/someCode.spec.ts'

我需要在 Sonarqube 属性中进行哪些配置,以便它了解哪些文件是测试文件以及哪些文件是源文件?

【问题讨论】:

  • 在 sonarqube 的项目设置中,您为测试文件提供的模式是什么?运行分析时也可以给出命令行。
  • 查看this 以获得一些提示。

标签: typescript sonarqube jestjs


【解决方案1】:

对我来说,即使添加了 sonar.test.inclusions=**/*-spec.js ,测试报告也不会出现。添加sonar.tests=.(same as sonar.sources)后它工作了

【讨论】:

    【解决方案2】:

    你可以试试

    sonar.sources = **/someDir/**/*
    sonar.tests = **/someDir/*
    //or
    sonar.sources = **/someDir/*
    sonar.tests = **/someDir/*
    

    取决于您是否有任何子目录。可能是列出测试和来源的所有位置的更好选择。

    【讨论】:

      【解决方案3】:

      似乎它没有检测到使用“.”的子文件夹中的文件。我能够让它工作的唯一方法是列出所有文件夹。

      sonar.sources=helpers,managers,routes,schemas,types
      sonar.tests=helpers,managers,routes,schemas,types
      sonar.exclusions=**/*.js,test-data,dist,coverage
      sonar.test.inclusions=**/*.spec.ts
      sonar.testExecutionReportPaths=test-report.xml
      sonar.typescript.lcov.reportPaths=coverage/lcov.info
      

      【讨论】:

        猜你喜欢
        • 2023-03-07
        • 2016-11-14
        • 2018-11-08
        • 1970-01-01
        • 1970-01-01
        • 2019-07-05
        • 1970-01-01
        • 1970-01-01
        • 2017-08-27
        相关资源
        最近更新 更多