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

Value of path attribute for File-element #13

Closed groie closed 8 years ago

groie commented 8 years ago

Hi, It seems that with my jasmine/karma tests the generic coverage file ends up being composed falsely. The value of "path" ends up being the value of the topmost describe block. This unfortunately does not work with SonarQube as sonar expects to get the actual path and filename.

<unitTest version="1">
  <file path="controller: SearchCtrl">

Are you using the filename+path as the value for the topmost describe block for each testfile, or how did you get this to work?

tornaia commented 8 years ago

Hi Groie,

%project%/test/app/components/applicationinfo/applicationinfo.service.spec.js:

(function() {
  'use strict';

  describe('test\\app\\components\\applicationinfo\\applicationinfo.service.spec.js', function() {
    var applicationInfoService;
    var $rootScope;

    describe('getApplicationInfo function invokes $http', function() {
...

thus the utreport.xml will be something like this:

<unitTest version="1">
  <file path="test/app/components/applicationinfo/applicationinfo.service.spec.js">
    <testCase name="test\app\components\applicationinfo\applicationinfo.service.spec.js getApplicationInfo function invokes $http invokes specific url" duration="39"/>
...

I know it is far from perfect but maybe will answer your question.. but might not solve your issue. Please let me know... :)

groie commented 8 years ago

I have a large existing base of Karma tests I'd like to display in SonarQube, thus this approach is not especially helpful. I think we'll build our own version of a Jasmine Reporter that exports parses and exports the filenames properly.