As everyone knows, automated tests are great since they let you test a system without the need of proactively checking anything: you launch your suite and you get a feedback; moreover, systems like Jenkins or Travis-CI allow you to even forget about checking the status of a build since they can do all of this work for you: the problem, instead, happens when you need to run the tests locally, as you always need to check the shell to know whether the tests passed or not.
A solution would be to launch the tests and mind your own business, instead of having to check the CLI output, waiting for a notification that tells use about the tests’ result.
Notifications to the rescue
A very simple program, written for Linux, can help
you with this task: it’s
Given that you have PHPUnit installed via composer
(so the binary is accessible at
you can simply use a small shell function that can
sends notifications about the tests’ results, that I
put on Github.
Clone the repository and add the shell function to your shell profile2:
1 2 3 4 5 6 7
At this point you can open a new shell and run your tests with
1 2 3 4 5 6 7 8 9 10 11
and see that as soon as the tests are over you will see one of those usual notifications on the top right of your screen, hopefully telling you that the automated tests suite is greener than ever.
notify-send utility is probably not available on
Macs, but I guess you can just replace it with
If you are interested into digging deeper into the topic, I would suggest you to read a very nice article from Giulio Di Donato which explains how to run PHPUnit tests for Symfony2 as soon as any file in your filesystem changes, and get the same type of notifications: even though I personally think this approach is a little bit too extreme3, it is anyhow interesting as it pushes automation and time-management to their best limits.
- Or, for example, to empty the tables of the right database after each test (there are different databases for each website) ↩
- I am personally using ZSH: https://github.com/robbyrussell/oh-my-zsh ↩
- If you modify 5 files and your test suite is 30secs long, woul will already have to wait 2 and a half minutes ↩