【发布时间】:2018-05-02 04:53:51
【问题描述】:
我正在使用 QUnit 运行单元测试,并尝试将 QUnit 集成到我们的构建自动化和持续集成过程中。为了让 Atlassian Bamboo 解析测试输出,它要求测试输出位于 xml 文件中。我可以使用 qunit-reporter-junit 插件生成所需 xml 格式的控制台日志。当 Gulp-QUnit 运行我们的 test-runner.html 文件时,它会将 console.log 输出到屏幕上。我的问题是我找不到将这个 console.log 输出通过管道传输到文件中的方法。
我尝试了以下方法:
使用 gulp-log-capture 插件(什么都不做):
gulp.task('qunit', function() {
return gulp.src('./qunit/test-runner.html')
.pipe(logCapture.start(console,'log'))
.pipe(qunit())
.pipe(logCapture.stop('build.xml'));
});
将输出通过管道传输到写入流中(这会引发错误):
gulp.task('qunit', function() {
return gulp.src('./qunit/test-runner.html')
.pipe(qunit())
.pipe(fs.createWriteStream('build.xml));
});
使用 gulp-out 插件(它只是将输入的 html 通过管道传输到新文件中):
gulp.task('qunit', function() {
return gulp.src('./qunit/test-runner.html')
.pipe(qunit())
.pipe(out('build.xml');
});
XML 就在屏幕上,我只需要以某种方式将其放入文件中。
【问题讨论】:
标签: javascript unit-testing gulp bamboo qunit