Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Pest test framework support #217

Merged
merged 1 commit into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/guide/command-line-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,35 @@ infection -j$(sysctl -n hw.ncpu)

### `--test-framework`

This is a name of the Test framework to use. Currently Infection supports `PHPUnit`, `PhpSpec` and `Codeception`.
This is a name of the Test Framework to use. Currently, Infection supports `PHPUnit`, `PhpSpec`, `Pest` and `Codeception`.

If you are using `infection/infection` Composer package, only `PHPUnit` is installed by default. Other test framework adapter will be automatically installed on demand.
[PHAR distribution](/guide/installation.html#Phar) is bundled with all available adapters.
If you are using `infection/infection` Composer package, `PHPUnit` and `Pest` are installed by default. Other test framework adapters will be automatically installed on demand.
[PHAR distribution](/guide/installation.html#Phar) is bundled with all available adapters.

>Feel free to request a new test framework to be supported out of the box in Github's issues.

### `--test-framework-options`

This options allows to pass additional options to the test framework. Example for `PHPUnit`:
This option allows passing additional options to the test framework. Example for `PHPUnit`:

```bash
infection.phar --test-framework-options="--verbose --filter=just/unit/tests"
```

This will execute the phpunit as:
This will execute the `PHPUnit` as:

```bash
phpunit [...infection options] --verbose --filter=just/unit/tests
```

> Please note that if you choose to use `--configuration`, `--filter`, or `--testsuite` for PHPUnit, these options will only be applied to the _initial_ test run. Each mutation has a custom `phpunit.xml` file generated for it which defines a single testsuite containing the tests which should be executed for that mutation. Applying `--filter` or `--testsuite` would not make sense in this context as the tests have already been filtered down.
> Please note that if you choose to use `--configuration`, `--filter`, or `--testsuite` for `PHPUnit`, these options will only be applied to the _initial_ test run. Each mutation has a custom `phpunit.xml` file generated for it which defines a single testsuite containing the tests which should be executed for that mutation. Applying `--filter` or `--testsuite` would not make sense in this context as the tests have already been filtered down.


### `--coverage`

Path to the existing coverage reports.

When you use Continuous Integration for your project, probably you are already generating code coverage metrics and run PHPUnit with `XDebug`/`phpdbg` enabled. Then, you run Infection for mutation testing, which in its turn, generates Code Coverage again for internal needs. This dramatically increases the build time because running your tests with debugger *twice* requires too much time.
When you use Continuous Integration for your project, probably you are already generating code coverage metrics and run PHPUnit with `Xdebug`/`phpdbg` enabled. Then, you run Infection for mutation testing, which in its turn, generates Code Coverage again for internal needs. This dramatically increases the build time because running your tests with debugger *twice* requires too much time.

With this option it's possible to reuse already generated coverage in Infection.

Expand Down Expand Up @@ -246,8 +246,8 @@ infection --log-verbosity=all

### `--initial-tests-php-options`

Run Initial Tests process with additional php options. For example with `-d zend_extension=xdebug.so` which will run Xebug only for code coverage.
May be useful for cases when XDebug is not enabled globally. Also it's useful from performance point of view.
Run Initial Tests process with additional php options. For example with `-d zend_extension=xdebug.so` which will run `Xdebug` only for code coverage.
May be useful for cases when `Xdebug` is not enabled globally. Also it's useful from performance point of view.
``` bash
infection --initial-tests-php-options="-d zend_extension=xdebug.so"
```
Expand Down
3 changes: 2 additions & 1 deletion src/guide/github-sponsors.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ If you like Infection, consider supporting us on GitHub Sponsors: https://github
* Thomas Rieschl **@rieschl** https://github.com/rieschl
* DeGraciaMathieu **@DeGraciaMathieu** https://github.com/DeGraciaMathieu
* Woda https://github.com/wwwoda
* Eric Braun **@oqq** https://github.com/oqq
* Eric Braun **@oqq** https://github.com/oqq
* Oleg Andreyev **@oleg-andreyev* https://github.com/oleg-andreyev
* Anonymous (1)
2 changes: 1 addition & 1 deletion src/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Infection is a **PHP mutation testing framework** based on AST (Abstract Syntax

> Read a [detailed post](https://medium.com/@maks_rafalko/infection-mutation-testing-framework-c9ccf02eefd1) about Mutation Testing and Infection on Medium

Infection currently supports `PHPUnit`, `PhpSpec` and `Codeception` test frameworks, requires PHP 7.4+ and Xdebug/phpdbg/pcov installed.
Infection currently supports `PHPUnit`, `PhpSpec`, `Pest` and `Codeception` test frameworks, requires PHP 7.4+ and Xdebug/phpdbg/pcov installed.

In a nutshell, it

Expand Down
4 changes: 2 additions & 2 deletions src/guide/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ order: 2

### Compatibility Note

Infection requires a recent version of PHP, and `XDebug`, `phpdbg`, or `pcov` enabled.
Infection requires a recent version of PHP, and `Xdebug`, `phpdbg`, or `pcov` enabled.

You can still use an older Infection version if you're using an older PHP version.

Expand All @@ -20,7 +20,7 @@ You can still use an older Infection version if you're using an older PHP versio

## Phar

Phar distribution is the best and recommended way of installing Infection on your computer. Unlike `infection/infection`, it is bundled with all officially supported Test Frameworks: `PHPUnit`, `PhpSpec`, `Codeception`.
Phar distribution is the best and recommended way of installing Infection on your computer. Unlike `infection/infection`, it is bundled with all officially supported Test Frameworks: `PHPUnit`, `PhpSpec`, `Pest` and `Codeception`.

Download the latest `infection.phar` and `infection.phar.asc`:

Expand Down
32 changes: 32 additions & 0 deletions src/guide/supported-test-frameworks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Supported Test Frameworks
type: guide
order: 15
is_new: false
---

Infection supports the following Test Frameworks:

* [PHPUnit](https://phpunit.readthedocs.io/en/latest/)
* [PhpSpec](http://www.phpspec.net/en/stable/)
* [Pest](https://pestphp.com/)
* [Codeception](https://codeception.com/)

If you are using [Phar distribution](/guide/installation.html#Phar) (downloading Phar or using [Phive](/guide/installation.html#Phive)), all the test frameworks are bundled into it.

If you are using `infection/infection` package, only `PHPUnit` and `Pest` are bundled. Additional Test Frameworks will be automatically installed on demand.

For example, running

```bash
infection --test-framework=codeception
```

will notice that adapter is not installed and it will propose to install it in the same process:

```bash
We noticed you are using a test framework supported by an external Infection plugin.
Would you like to install infection/codeception-adapter? [yes]:

Installing infection/codeception-adapter...
```
7 changes: 3 additions & 4 deletions src/guide/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,20 @@ You can commit it to the VCS and, if necessary, override it locally by creating
* `minCoveredMsi` - optional key, a value for the Minimum Covered Code Mutation Score Indicator (MSI) percentage value
* `mutators`: optional key, it contains the settings for different mutations and profiles, read more about it [here](/guide/profiles.html)
* `testFramework`: optional key, it sets the framework to use for testing. Defaults to `phpunit`. This gets overridden by the `--test-framework` command line argument.
* `bootstrap`: optional key, use to specify a file to include as part of the startup to pre-configure the Infection environment. Useful for adding custom autoloaders not included in composer.
* `bootstrap`: optional key, use it to specify a file to include as part of the startup to pre-configure the Infection environment. Useful for adding custom autoloaders not included in composer.
* `initialTestsPhpOptions`: optional key, specify additional php options for the initial test (IE: Enabling X-Debug). `--initial-tests-php-options` will override this option.
* `testFrameworkOptions`: optional key, specify additional options to pass to the test framework (IE: Enabling Verbose Mode). `--test-framework-options` will override this option.

#### How to use custom autoloader or bootstrap file

If you have a custom autoloader or bootstrap file for your application, you should tell Infection about it.

For example you have
For example, you have

```php
// custom-autoloader.php

require NonPsr4CompliantFile.php

require 'NonPsr4CompliantFile.php';
```

then you have to add it to the `infection.json` file:
Expand Down