testomat/phpunit-printer

This package is abandoned and no longer maintained. No replacement package was suggested.

:crystal_ball: PHPUnit printer, assertion and more...

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Type:phpunit-printer

dev-master / 1.0.x-dev 2020-05-02 13:58 UTC

This package is auto-updated.

Last update: 2024-02-26 09:49:23 UTC


README

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746573746f6d61742f706870756e69742d7072696e7465722e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545372e332e302d3838393242462e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746573746f6d61742f706870756e69742f6d61737465722e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c253230372d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265266c6162656c3d7068707374616e 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265

Provides a PHPUnit printer class, with:

  • beautiful error reporting
  • slow-running tests reporting
  • over assertive test reporting
  • provides a beautiful text-coverage output
  • provides output for a compact and expanded test runner view

Installation

Run

$ composer require testomat/phpunit-printer

Usage

Enable the printer by adding the following to your phpunit.xml or phpunit.xml.dist file:

<phpunit
    printerClass="Testomat\PHPUnit\Printer\Printer">
</phpunit>

Now run your test suite as normal.

Configuration

Within the configuration file testomat.xml a number of options can be passed to the printer.

First create a testomat.xml in the root folder of your project and copy this into it.

<?xml version="1.0" encoding="UTF-8"?>
<testomat
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="vendor/testomat/phpunit-common/Schema/testomat.xsd"
>
... printer configuration
</testomat>

Printer settings

The printer comes with 2 types of printer views expanded and compact (default). To change the printer view, use the type argument.

    <printer type="expanded"/>

You want to change how the errors printed by the PHPUnit printer, use the show_error_on option.

    <printer show_error_on="end"/>

To print the error after a failed test use show_error_on="test", default is to print the errors after the test runner finished.

Note: the printer supports all PHPUnit stopOn... settings.

To reduce the exception trace on the beautiful error output, use the <exclude>...</exclude> argument.

    <printer>
        <exclude>
            <directory>vendor/phpunit/phpunit/src</directory>
            <directory>vendor/mockery/mockery</directory>
        </exclude>
    </printer>

Note: The PHPUnit and Mockery exception trace, is filtered out by default.

Speed trap settings

By default, the speed trap collector is active, to deactivate the speed trap use enabled="false".

    <speedtrap enabled="false"/>

To change the overall suite threshold from 500 (default) to something higher use the <slow_threshold>500</slow_threshold> argument.

    <speedtrap>
        <slow_threshold>1000</slow_threshold>
    </speedtrap>

or PHPUnit annotations, the @slowThreshold annotation can be added to test classes or test methods to override any suite or group thresholds:

/**
 * @slowThreshold 2000
 */
class SomeTestCase extends \PHPUnit\Framework\TestCase
{
    /**
     * @slowThreshold 5000
     */
    public function testLongRunningProcess()
    {
    }
}

To change the default speed trap report length of 10 lowest tests, use the <report_length>10</report_length> argument.

    <speedtrap>
        <report_length>20</report_length>
    </speedtrap>

Over assertive settings

By default, the over assertive collector is active, to deactivate the over assertive use enabled="false".

    <over_assertive enabled="true"/>

To change the overall suite assertion from 10 (default) to something higher use the <threshold>10</threshold> argument.

    <over_assertive>
        <threshold>15</threshold>
    </over_assertive>

or PHPUnit annotations, the @assertionThreshold annotation can be added to test classes or test methods to override any suite or group thresholds:

/**
 * @assertionThreshold 15
 */
class SomeTestCase extends \PHPUnit\Framework\TestCase
{
    /**
     * @assertionThreshold 20
     */
    public function testLongRunningProcess()
    {
        self::assertTrue(true);
        ...
    }
}

To change the default over assertive report length of 10 assertions per tests, use the <report_length>10</report_length> argument.

    <over_assertive>
        <report_length>20</report_length>
    </over_assertive>

Versioning

This library follows semantic versioning, and additions to the code ruleset are performed in major releases.

Changelog

Please have a look at CHANGELOG.md.

Contributing

Please have a look at CONTRIBUTING.md.

Code of Conduct

Please have a look at CODE_OF_CONDUCT.md.

License

This package is licensed using the MIT License.

Please have a look at LICENSE.md.