Last Updated: February 25, 2016
· lukemadhanga

Run a specific set of PHPUnit scripts at once

So you write a totez amaze (I think that's the lingo the young 'uns use these days) Content Management System and all of the relevant PHPUnit test files for your scripts. The next thing you do is realise that running specific test files individually takes for ever - but that's okay because you use a unix OS and have a terminal that actually works!

Below is a small shell script that searches the folder unittests for PHP files labelled something like tCore*.php and then runs them.

# rununittests
for file in `sudo find unittests -name tCore*.php`;
        echo "Unit test for $file"
        phpunit --verbose --bootstrap index.php $file;

The above script assumes your directory structure is something like








Change unittests to the uppermost directory that covers all of your unittests, and tCore*.php to a valid expression that runs the specific files that you want.

You can then run this script using a simple


NB If you want to run all of the PHPUnit scripts in a folder, simply supply PHPUnit with the name of that folder and it will do the rest for you

1 Response
Add your response

over 1 year ago ·