DEV Community

Backlog Slayer
Backlog Slayer

Posted on

PHP: Testing only changes


Ref: USATF Mid-Atlantic

I recently found this awesome 😍 tool that let me run tests on only files that have been modified since the last commit, like I'm familiar with in the Jest framework.

Because I couldn't find a way to do this with PHPUnit Watcher or PHPUnit itself, and it worked for me with a few minor blocks, I have decided to share.

If you know how, please tell me in the comments.

The Blocker

The package's PHPUnit dependency was marked as ^6.0, so it wasn't working on my project, which had a dependency marked as ^7.0.

The Fix

I've made a fork here and I use its dev-master branch in my project by adding it to composer.json like:

"repositories": [
        "type": "vcs",
        "url": ""
"require-dev": {
    "icyapril/whats-changed": "dev-master"
Enter fullscreen mode Exit fullscreen mode

This is so that composer resolves the package from my GitHub fork rather than use the official package.


Now, when run ./vendor/bin/whatschanged, I get:

tests/Feature/AuthTest.php     OK (3 tests, 6 assertions)
tests/Feature/IntentTest.php   OK (5 tests, 21 assertions)
Enter fullscreen mode Exit fullscreen mode

rather than


🎉💃 Happy Coding!

Top comments (0)