I like many developers love test driven development so in this short tutorial, I'll show you how to use an awesome package to spice up your
PHPUnit test results by adding Nyancats to the printer results.

Requirements

Please make sure that you have the following:

  • PHPUnit
  • Composer
  • PHP 5.3.3 or later.
  • A terminal emulator with support for ANSI escape sequences, including color and cursor control.

Installation

Add the following to your composer file:

{
    "require-dev": {
        "whatthejeff/nyancat-phpunit-resultprinter": "~1.2"
    }
}

You will then have to run composer update to install the new dependencies that you added to your composer.json file.

Screen Shot 2017 10 05 at 10 10 03 AM

Once installed, open your phpunit.xml and add the following attributes to the <phpunit> element.

printerFile="vendor/whatthejeff/nyancat-phpunit-resultprinter/src/NyanCat/PHPUnit/ResultPrinter.php"
printerClass="NyanCat\PHPUnit\ResultPrinter"

Running Tests

Once installed, you can simply run your PHPUnit tests as per normal:

vendor/bin/phpunit

If everything worked as intended, you should now see an awesome Nyancat with your test results!

Screen Shot 2017 10 05 at 10 10 50 AM

Let me know if you have any questions or feedback in the comments below.