Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonar generic test report - file path issue with SQ 7.9 #44

Open
subashiniunny opened this issue Nov 5, 2019 · 4 comments
Open

Sonar generic test report - file path issue with SQ 7.9 #44

subashiniunny opened this issue Nov 5, 2019 · 4 comments

Comments

@subashiniunny
Copy link

As a part of the drop of modules on the SonarQube side (https://jira.sonarsource.com/browse/MMF-365) in SonarQube v7.6, the generic coverage/test reports sensors were changed to be global sensors (https://jira.sonarsource.com/browse/SONAR-11530), meaning they only run once for the project (and not for each module). To address this, we need to provide the paths to all generic execution reports to sonar.testExecutionReportPaths at the root level of the project. In the case of a multi-module project, we have the generic test report using this karma-sonarqube-unit-reporter being generated inside a javascript module and the file path of the test files inside the results xml file is all relative to that module. This does not work.
These test file paths need to be relative to the root folder or absolute file paths, otherwise the generic test execution sensor running at the root level is unable to recognize these files.

@Agnaro
Copy link

Agnaro commented Feb 28, 2020

I had the same issue and was able to work around the issue by using the filenameFormatter config option to define a custom formatter for the path (overrideTestDescription must be false).

@gfortaine
Copy link

gfortaine commented Nov 3, 2020

It looks like that overrideTestDescription was a better path for us (unfortunately, it seems that filenameFormatter as previously suggested doesn't provide current file path) :

sonarQubeUnitReporter: {
     sonarQubeVersion: "LATEST",
     outputDir: "coverage/",
     outputFile: "test-report.xml",
     useBrowserName: false,
     overrideTestDescription: true,
     testPaths: ['./test'],
     testFilePattern: /\.test\.[jt]sx?$/,
     prependTestFileName: "apps/portal"
 }

@radhey24h
Copy link

Thanks @gfortaine ,

You make my day.

@Wusulijiang13
Copy link

Thanks a lot @gfortaine
That works for me and I fix it with adding prefix of absolute path

sonarQubeUnitReporter: {
      sonarQubeVersion: "9.x",
      outputFile: "./coverage/unit-test-result.xml",
      overrideTestDescription: true,
      testFilePattern: ".spec.ts",
      useBrowserName: false,
      prependTestFileName: __dirname
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants