9

GitHub - robiningelbrecht/phpunit-pretty-print: Better PHPUnit CLI output with C...

 1 year ago
source link: https://github.com/robiningelbrecht/phpunit-pretty-print
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Better PHPUnit CLI output

PHPUnit

I really like how Pest PHP formats and outputs test results, but I still prefer to use PHPUnit. Luckily there's Collision. This package is designed to give you beautiful error reporting when interacting with your app through the command line.

Installation

composer require robiningelbrecht/phpunit-pretty-print --dev

Configuration

Navigate to your phpunit.xml.dist file and add following config to set default options (you can also set these options at run time):

<extensions>
    <bootstrap class="RobinIngelbrecht\PHPUnitPrettyPrint\PhpUnitExtension">
    </bootstrap>
</extensions>

Also make sure the color attribute is set to true:

<phpunit 
        colors="true">
</phpunit>

Options

  • Output profiling report at the end of the test run
<extensions>
    <bootstrap class="RobinIngelbrecht\PHPUnitPrettyPrint\PhpUnitExtension">
        <parameter name="displayProfiling" value="true"/>
    </bootstrap>
</extensions>
  • Use compact mode to only output the testsuite results instead of all separate tests
<extensions>
    <bootstrap class="RobinIngelbrecht\PHPUnitPrettyPrint\PhpUnitExtension">
        <parameter name="useCompactMode" value="true"/>
    </bootstrap>
</extensions>
  • Feel good about yourself after running your testsuite by displaying a Chuck Noris quote
<extensions>
    <bootstrap class="RobinIngelbrecht\PHPUnitPrettyPrint\PhpUnitExtension">
        <parameter name="displayQuote" value="true"/>
    </bootstrap>
</extensions>

Usage

> vendor/bin/phpunit

Example default

Print profiling

> vendor/bin/phpunit -d --profiling

Example profiling

Use compact mode

> vendor/bin/phpunit -d --compact

Example compact

Display Chuck Norris quote

> vendor/bin/phpunit -d --display-quote

Example quote

Combine multiple options

> vendor/bin/phpunit --configuration=tests/phpunit.test.xml -d --compact -d --display-quote

Acknowledgements


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK