|
| 1 | +# PHPUnit Presenter |
| 2 | + |
| 3 | +Displays the PHPUnit test results in a more presentable and friendly format. The Presenter includes timings for tests, |
| 4 | +colour support and better displays of errors and failures. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +## Features |
| 9 | + |
| 10 | +- Different formatting types depending on your preferences. |
| 11 | +- Grouping of test cases and suites. |
| 12 | +- Time taken for each test case. |
| 13 | +- Optional colour support. |
| 14 | + |
| 15 | +## How to use |
| 16 | + |
| 17 | +Simply include this library via Composer: |
| 18 | + |
| 19 | +``` |
| 20 | +composer require --dev abwebdevelopers/phpunit-presenter |
| 21 | +``` |
| 22 | + |
| 23 | +And then add it to your `phpunit.xml` file as the `printerClass` attribute |
| 24 | + |
| 25 | +```xml |
| 26 | +<phpunit |
| 27 | + ... |
| 28 | + printerClass="ABWebDevelopers\PHPUnitPresenter\Presenter" |
| 29 | + ... |
| 30 | +> |
| 31 | +``` |
| 32 | + |
| 33 | +## Configuration |
| 34 | + |
| 35 | +The Presenter can be configured via environment variables. The following environment variables are used: |
| 36 | + |
| 37 | +Environment Variable | Default | Description |
| 38 | +---------------------|---------|------------ |
| 39 | +`PRESENTER_SHOW_TIMES` | `1` | Displays the time taken for test cases. Set to `0` to disable. |
| 40 | +`PRESENTER_COLOURS` | `1` | Displays colouring of CLI output. Set to `0` to disable. It is recommended to disable colours for test environments, ie. Travis CI. |
| 41 | +`PRESENTER_HIDE_SUCCESSFUL` | `0` | If enabled, will hide all successful tests, and only show failed or errored tests. Set to `1` to enable. |
| 42 | +`PRESENTER_FORMAT` | `default` | Sets the format used to display results via Presenter. Valid values are `default`, `feed` and `condensed`. It is recommended to use `feed` or `condensed` for test environments, ie. Travis CI. |
| 43 | + |
| 44 | +## Formats |
| 45 | + |
| 46 | +There are three types of formatting of the results displayed by Presenter - `default`, `feed` and `condensed`. |
| 47 | + |
| 48 | +`default` and `feed` display the same information (shown in the screenshot above), however, `default` uses CLI line overwriting to show real-time progress of tests. This may not work with some log readers used in test environments (such as Travis CI), so it is recommended to use `feed` for test environments. |
| 49 | + |
| 50 | +A third format `condensed` presents test results in a condensed format closer to PHPUnit's default result printer. When using `condensed`, it is implied that `PRESENTER_SHOW_TIMES` is set to `0`. The formatting of condensed looks similar to this: |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +## License |
| 55 | + |
| 56 | +MIT. |
0 commit comments