dylanb / gulp-coverage

Gulp coverage reporting for Node.js that is independent of the test runner
MIT License
60 stars 12 forks source link

sloc value is different from that reported by gulp-sloc due to not showing _All_ files #47

Open Smurf-IV opened 8 years ago

Smurf-IV commented 8 years ago

gulp-sloc reports this:

    physical lines : 21163

lines of source code : 16045 total comment : 2533 singleline : 1044 multiline : 1489 empty : 2585

number of files read : 65

strict mode

gulp-coverage reports this: "sloc": 3587, "ssoc": 6711, "sboc": 1251, "coverage": 37.97044884304432, "statements": 35.2853524064968, "blocks": 27.018385291766588, And lists only 35 files

Why are files missing ?

FYI: Notice that the source lists are the same // ========================== gulp.task('linesOfCode', function(){ gulp.src(['./../Server/source//_.js']) .pipe(sloc()); }); // ========================== gulp.task('nodeuniter', ['cleanuniter'], function () { var stream = gulp.src(['./testing/.js'], {read: false}) .pipe(cover.instrument({ pattern: ['./../Server/source//*.js'], debugDirectory: './.debug' })) .pipe(nodeunit({ reporter: 'junit', reporterOptions: { output: './.unitReport' } })) .pipe(cover.gather()) .pipe(cover.format([{reporter: 'html'}, {reporter: 'json'}])) .pipe(gulp.dest('./.covReport')); return stream; }); // ==========================

Smurf-IV commented 8 years ago

So found out that if the gulp.src does not load the files, then they will not be included in the coverage calculation, i.e. if the following does not require a code file then it will not be piped into the instrument step

var stream = gulp.src(['./testing/*.js'], {read: false})

makes sense

So I tried this line

var stream = gulp.src(['./testing/_loadAllSource.js'], {read: false})

which has the following in the code

var modules = require('require-dir-all')( path.resolve(__dirname, '../../Server/source'), { recursive: true, includeFiles: /^.*.(js)$/, excludeDirs: /^(.git|.svn|node_modules)$/ } );

BUT That attempts to start my server code, which is not the point, as the Unit tests should be loading just the bits they need in a standalone fashion.

So what is needed is some way of getting all the target files into the instrument step without them starting up or loading files etc.

dylanb commented 8 years ago

This module will only give you coverage stats for files that are tested with unit tests. That is a current limitation. Are there files that are being tested with unit tests that are being excluded?