gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 787 forks source link

How to combine the multiple coverage results from various folders to a single html file? #847

Open thirusabari opened 7 years ago

thirusabari commented 7 years ago

I am new to TDD. we have already executed the test cases through karma-coverage.. If the test case count increases, the code coverage took more time to complete the job. so i had switched into concurrenlty to implement the parallel test case execution. Before that, the code coverage results are generated as single html file. But now, i had configure the coverage results into separate folders to improve the performance on test cases. But now, the coverage results are generated as separate html report. But i want to combine these separate folder's index.html file into single html report.

so that, i have implemented the parallel execution of my repository using "concurrently". I had configured the gulp generate the separate code coverage reports for each folder. Each folder has set of .spec file The gulp configuration details is given below,

gulp zero:

` coverageReporter: {

        dir: './cireports',

        subdir: "codecoverage/zero",

        reporters: [
            { type: 'html', file: "UnitTestCover.html" },
        ]

    }

` gulp one:

` coverageReporter: {

        dir: './cireports',

        subdir: "codecoverage/one",

        reporters: [
            { type: 'html', file: "UnitTestCover.html" },
        ]

    }

` gulp two:

` coverageReporter: {

        dir: './cireports',

        subdir: "codecoverage/two",

        reporters: [
            { type: 'html', file: "UnitTestCover.html" },
        ]

    }

`

gulp three:

` coverageReporter: {

        dir: './cireports',

        subdir: "codecoverage/three",

        reporters: [
            { type: 'html', file: "UnitTestCover.html" },
        ]

    }

`

If I executed following command through command prompt,

**concurrently “gulp zero” “gulp one” “gulp two” “gulp three”** 

Test case was executed parallel and the coverage reports generated in the specific folder. Each coverage folder has index.html file. So I need to merge the coverage reports from all folders into single index.html file.

I had tried to merge the coverage reports from following package, 1. So that I had installed the “gulp-concat” from following command,

npm install --save -dev gulp-concat

After that, I had configure the gulp.js to merge the coverage reports, The gulp-concat configuration is given below,

gulp-concat:

` gulp.task('merge', function () {

return gulp.src(['./cireports/codecoverage/zero/index.html', './cireports/codecoverage/one/index.html', './cireports/codecoverage/two/index.html', './cireports/codecoverage/three/index.html'])
  .pipe(concat('index.html'))
  .pipe(gulp.dest('./dist/'));

});

` After test case execution completed, I had executed the “gulp merge” to merge the coverage reports. Expected output was not came. The merged index.html file was generated the series of coverage reports in a single index file

Can anyone tell me whether there is any plan to implement the merging of coverage reports?

Regards,

Creator