Skip to content

Instantly share code, notes, and snippets.

@arialdomartini
Last active April 20, 2018 10:56
Show Gist options
  • Save arialdomartini/dd7d3f1e2428dfbf5262b571ed66955b to your computer and use it in GitHub Desktop.
Save arialdomartini/dd7d3f1e2428dfbf5262b571ed66955b to your computer and use it in GitHub Desktop.
gulp xunit cover
gulp.task('test', "Run all the tests", ["build", "tools:download:xunit-runner"], function() {
console.log(config.tools.xunit.path)
var options = {
executable: config.tools.xunit.path,
options: {
nologo: true,
xml: config.testResult
}
}
var assemblies = [`../**/bin/${config.buildConfiguration}/*.Test.dll`]
return gulp.src(assemblies, {read: true}).pipe(xunit(options));
})
// Possibile approccio
gulp.task('cover', "Run test code coverage and outputs an html report", [], () => {
var through = require('through2');
var assemblies = [`../**/bin/${config.buildConfiguration}/*.Test.dll`]
var fileList = []
gulp.src(assemblies)
.pipe(through.obj(function (file, enc, cb) {
fileList.push(file.path);
cb(null);
}))
.pipe(gulp.dest('./temp/'))
.on ('end', function () {
console.log(fileList);
});
})
//altro approccio
gulp.task('cover', "Run test code coverage and outputs an html report", [], () => {
var through = require('through2');
var assemblies = [`../**/bin/${config.buildConfiguration}/*.Test.dll`]
gulp.src(assemblies)
.pipe(concatNames())
.on('data', names => {
console.log(names)
})
function concatNames() {
var names = []
function bufferContents(file, enc, cb) {
names.push(file.path)
cb(null)
}
function endStream() {
this.emit('data', names.join(' '));
this.emit('end');
}
return through.obj(bufferContents, endStream);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment