PHP: Testing only changes

mykeels

Backlog Slayer

Posted on July 13, 2018

PHP: Testing only changes

changes

Ref: [USATF Mid-Atlantic](https://mausatf.com/background-screening-process-changes/)

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": "https://github.com/mykeels/WhatsChanged"
    }
],
"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.

Usage

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

image

šŸŽ‰šŸ’ƒ Happy Coding!

šŸ’– šŸ’Ŗ šŸ™… šŸš©
mykeels
Backlog Slayer

Posted on July 13, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

PHP: Testing only changes
phpunit PHP: Testing only changes

July 13, 2018