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

File path in 'ut_report.xml' #2

Closed ThaKing closed 7 years ago

ThaKing commented 8 years ago
  1. Test present in folders "test/unit/some/someTest.js"
  2. I should write full path in this test

"describe('test/unit/some/someTest.js', function() {}"

for 'ut_report.xml' in file tag

<unitTest version="1"> <file path="test/unit/someTest.js"> <------ should paste from describe in test <testCase name="Some Test ..." duration="18"/> </file> </unitTest>

Could it be possible to auto generate this'<file path="test/unit/someTest.js">'in ut_report.xml despite on describe in test?

tornaia commented 8 years ago

Unfortunately this is not possible since the required information (path to the executed test file) is not passed to this plugin.

karma-sonarqube-unit-reporter\index.js#115: this.specSuccess = this.specSkipped = this.specFailure = function (browser, result) {

This method is some kind of entry point to this plugin where browser is a reference to headless browser instance (in my case) and result has the following content:

Object
    description: "invokes specific url"
    id: "spec0"
    log: Array[0]
    skipped: false
    success: true
    suite: Array[2]
        0: "test\app\components\applicationinfo\applicationinfo.service.spec.js"
        1: "getApplicationInfo function invokes $http"
        length: 2
    time: 32

where suite[0] is the top level describe, suite[1] is the nested one and description equals to the it.

jehon commented 7 years ago

Hello

I pushed it to jasmise framework here: https://github.com/jasmine/jasmine/issues/1256

For mocha, the information is already present here, if I read that correctly: https://github.com/mochajs/mocha/pull/1222

Perhaps it could be nice to prepare this...

tornaia commented 7 years ago

Investigating

tornaia commented 7 years ago

Fix in PR#17: https://github.com/tornaia/karma-sonarqube-unit-reporter/pull/17