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
Run
$ composer require testomat/phpunit-printer
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.
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>
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.
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>
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>
This library follows semantic versioning, and additions to the code ruleset are performed in major releases.
Please have a look at CHANGELOG.md
.
Please have a look at CONTRIBUTING.md
.
Please have a look at CODE_OF_CONDUCT.md
.
This package is licensed using the MIT License.
Please have a look at LICENSE.md
.