Run PHPUnit tests on change

后端 未结 10 1719
星月不相逢
星月不相逢 2021-02-07 11:34

I\'d like to run my PHPUnit tests (or at least a subset of them) whenever a file changes on disk. Very similar to what you can do with \"grunt watch\". I have a project in which

10条回答
  •  故里飘歌
    2021-02-07 11:59

    i found this solution use node+gulp

    0. install node 
    1. npm init 
    2. npm install gulp --save-dev
    

    create a gulpfile.js and put this

    var gulp = require('gulp'),  
    util = require('util'),
    exec = require('child_process').exec;
    
    gulp.task('phpunit', function() {
        exec('phpunit -c my_project_name/App', function(error, stdout) {
            util.puts(stdout); 
        });
    }); 
    
    gulp.task('default',['phpunit'], function() {
        gulp.watch('my_project_name/**/*.php', ['phpunit']);
    
    });
    

    my_project_name/App is the path of all source code

    if add extension add this line on default task

    gulp.watch('my_project_name//*.otherext', ['phpunit']);

    after edit php file run the phpunit test

提交回复
热议问题