tornaia / karma-sonarqube-unit-reporter

A Karma plugin. Unit tests execution report for SonarQube/Generic Coverage Plugin
MIT License
33 stars 28 forks source link

FAils to generae path for test report. generated xml doesnt have path to test #34

Open shrutigv opened 5 years ago

shrutigv commented 5 years ago

report.xml `

` generated path doesnt point to test.

Elegie commented 5 years ago

Hello, I had the same problem, and I fixed it by simply adding "overrideTestDescription: true" in the Karma sonarQubeUnitReporter configuration, as described in the README.

Here's the relevant section: sonarQubeUnitReporter: { sonarQubeVersion: 'LATEST', outputFile: '../reports/ut_report.xml', overrideTestDescription: true, testPaths: ['./src'], testFilePattern: '.spec.ts', useBrowserName: false }

dmytro-afonin commented 5 years ago

The same for me. Looks like if I I have and angular 8 application with default karma.conf. After I added the next config, the generated report does not includes the paths of components.

sonarQubeUnitReporter: {
sonarQubeVersion: 'LATEST',
outputFile: '../reports/ut_report.xml',
useBrowserName: false
}

so I tried to add the next one, but in this time it started throwing me an error

TypeError: Cannot read property 'value' of undefined
    at SonarQubeUnitReporter.specSuccess.specSkipped.specFailure (/<my_path>/node_modules/karma-sonarqube-unit-reporter/index.js:153:95)
sonarQubeUnitReporter: {
sonarQubeVersion: 'LATEST',
outputFile: '../reports/ut_report.xml',
overrideTestDescription: true,
testPaths: ['./src'],
testFilePattern: '.spec.ts',
useBrowserName: false
}
dmytro-afonin commented 5 years ago

I found a few workarounds on this.

  1. Try to add all 4 properties

      overrideTestDescription: true,
      testPath: './src',
      testPaths: ['./src'],
      testFilePattern: '.spec.ts'
  2. the second approach I found in https://github.com/tornaia/karma-sonarqube-unit-reporter/issues/24 this related issue

just override a function In both cases the code start working and the paths became valid