Skip to content

Instantly share code, notes, and snippets.

@acavanagh
Created October 8, 2014 16:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save acavanagh/7ba1ee5724bdbeb45525 to your computer and use it in GitHub Desktop.
Save acavanagh/7ba1ee5724bdbeb45525 to your computer and use it in GitHub Desktop.
Gulp file to run phpunit and behat tests
//gulpfile.js
var gulp = require('gulp');
var beep = require('beepbeep');
var sys = require('sys');
var exec = require('child_process').exec;
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');
var onError = function(err) {
beep([1000, 1000, 1000]);
gutil.log(gutil.colors.red(err));
}
var onSuccess = function(message) {
gutil.log(gutil.colors.green(message));
}
// Run all PHPUnit tests
gulp.task('phpunit', function() {
exec('phpunit tests/BehatEditor/Tests/ProjectServicesTest.php', function(error, stdout) {
if(error !== null)
{
onError(stdout);
}
else
{
onSuccess(stdout);
}
});
exec('phpunit tests/BehatEditor/Tests/BehatTestServiceTest.php', function(error, stdout) {
if(error !== null)
{
onError(stdout);
}
else
{
onSuccess(stdout);
}
});
});
gulp.task('behat', function() {
exec('bin/behat --config=tests/behat/behat.yml tests/behat/features/api/tests_api.feature', function(error, stdout) {
if(error !== null)
{
onError(stdout);
}
else
{
onSuccess(stdout);
}
});
});
gulp.task('watch', function () {
gulp.watch('app/**/*.php', ['phpunit', 'behat']);
gulp.watch('tests/BehatEditor/Tests/*', ['phpunit']);
gulp.watch('tests/behat/features/*', ['phpunit']);
});
gulp.task('default', ['watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment