Sonarqube test report “report refers to a file which is not configured as a test file” when tests and source are together

╄→гoц情女王★ 提交于 2020-04-13 09:11:16

问题


I am using TypeScript and Jest and have my tests next to my source files. e.g:

  • someDir
    • someCode.ts
    • someCode.spec.ts

When I try and import the text-report.xml (which looks to be fine and matches the format), I get an error saying:

'Line X report refers to a file which is not configured as a test file: /someDir/someCode.spec.ts'

What configuration do I need in in the Sonarqube properties so that it understand which files are tests and which are source?


回答1:


Seems it doesn't detect files in sub-folders using ".". Only way I was able to get it working was to list all of the folders.

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



回答2:


You can try

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

Depending on if you have any sub-directories. Might be a better alternative to listing all locations for both tests and sources.



来源:https://stackoverflow.com/questions/57466369/sonarqube-test-report-report-refers-to-a-file-which-is-not-configured-as-a-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!