karma-sonarqube-unit-reporter icon indicating copy to clipboard operation
karma-sonarqube-unit-reporter copied to clipboard

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

Open shrutigv opened this issue 6 years ago • 3 comments

report.xml <testExecutions version="1"> <file path="Async testing"> <testCase name="Async testing Token - Async test for token to be defined" duration="3661"/> </file> <file path="UNIT TESTING - Base API CLASS - Method Definitions"> <testCase name="UNIT TESTING - Base API CLASS - Method Definitions Base api - detectCompatibility method defined" duration="1"/> <testCase name="UNIT TESTING - Base API CLASS - Method Definitions Base api - removeSalt method defined" duration="1"/> <testCase name="UNIT TESTING - Base API CLASS - Method Definitions Base api - addSalt method defined" duration="1"/> <testCase name="UNIT TESTING - Base API CLASS - Method Definitions Base api - setSalt method defined" duration="1"/> </file> <file path="UNIT TESTING - BASE API CLASS - return type and argument type"> <testCase name="UNIT TESTING - BASE API CLASS - return type and argument type UNIT TESTING - detectCompatibility function return Type= boolean and argument of type=string(has default value) " duration="4"/> <testCase name="UNIT TESTING - BASE API CLASS - return type and argument type UNIT TESTING - addSalt function return Type= String and argument of type= String " duration="1"/> <testCase name="UNIT TESTING - BASE API CLASS - return type and argument type UNIT TESTING - setSalt function return Type= String and argument of type = String " duration="1"/> <testCase name="UNIT TESTING - BASE API CLASS - return type and argument type UNIT TESTING - removeSalt function return Type= String and argument of type = String " duration="1"/> </file> <file path="Async testing"> <testCase name="Async testing Token - Async test for token to be defined" duration="2527"/> </file> </testExecutions> generated path doesnt point to test.

shrutigv avatar Jan 09 '19 05:01 shrutigv

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 }

Elegie avatar Mar 29 '19 08:03 Elegie

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 avatar Sep 03 '19 12:09 dmytro-afonin

I found a few workarounds on this.

  1. Try to add all 4 properties
      overrideTestDescription: true,
      testPath: './src',
      testPaths: ['./src'],
      testFilePattern: '.spec.ts'
  1. 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

dmytro-afonin avatar Sep 03 '19 13:09 dmytro-afonin