Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/robiningelbrecht/phpunit-pretty-print

Better PHPUnit CLI output with Collision
https://github.com/robiningelbrecht/phpunit-pretty-print

php8 phpunit10 pretty-print testing website

Last synced: about 2 months ago
JSON representation

Better PHPUnit CLI output with Collision

Awesome Lists containing this project

README

        

Better PHPUnit CLI output


PHPUnit


CI
License

PHPStan Enabled
PHP
PHPUnit
PHPUnit

---

I really like how [Pest PHP](https://pestphp.com/) formats and outputs test results,
but I still prefer to use [PHPUnit](https://phpunit.de/). Luckily there's [Collision](https://github.com/nunomaduro/collision).
This package is designed to give you beautiful error reporting when interacting with your app through the command line.

## Installation

```bash
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):

```xml


```

Also make sure the `color` attribute is set to `true`:

```xml

```

## Options

All these options can be set at runtime as well, see usage.

### Output profiling report

```xml



```

### Enable compact mode

```xml



```

### Feel good about yourself after running your testsuite by displaying a Chuck Noris quote

```xml



```

### Disable pretty print.

This can be useful when you only want to prettify the output when forced via CLI (see usage).

```xml



```

## Usage

```bash
> vendor/bin/phpunit
```


Example default

### Output profiling report

```bash
> vendor/bin/phpunit -d --profiling
```


Example profiling

### Enable compact mode

```bash
> vendor/bin/phpunit -d --compact
```


Example compact

### Display Chuck Norris quote

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


Example quote

### Enable/disable pretty print

```bash
> vendor/bin/phpunit -d --enable-pretty-print
> vendor/bin/phpunit -d --disable-pretty-print
```

### Combine multiple options

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

## PHPUnit 9.x

This package does not support PHPUnit 9.x but Collision does out of the box. Run

```bash
composer require nunomaduro/collision:^6.0
```

Then add the Collision `printerClass` to your `phpunit.xml` in the `phpunit` section:

```xml

```

## Acknowledgements

* API used for Chuck Noris quotes: https://api.chucknorris.io/
* CLI formatting: https://github.com/nunomaduro/collision