PHPUnit – Run all tests in current directory

I figured out this bash command at some point when I needed to run all my PHPUnit tests in a directory at once, tweeted about it, but I keep having a hard time googling for it since.

Here it is:

for FILE in $(ls); do phpunit $FILE; done

Published by

Dan Bernardic

A Winnipeg Web programmer. Proud member of the Skip the Dishes team. Experienced with Web technologies, e.g. HTML5, CSS, ( Server-side ) JS, PHP, WordPress, MVC, etc.

3 thoughts on “PHPUnit – Run all tests in current directory”

  1. That seems terrible. If you have a lot of tests, you may or may not notice if test 1 is failing in all the burb from tests 2 – 1000. Isn’t there a phpunit way to define suites and run them?

    1. Thanks Rob,

      I have no idea why I needed it / found it useful then. Maybe I needed to run all in one directory, or something.

      Unfortunately I don’t know how to organize phpunit tests into suites. Haven’t used phpunit in a while. I’ve used peridot in PHP more recently, and now I use mocha in JavaScript.

      Let me know what you find.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s