raneomik / infection-tester-adapter
Tester Adapter for Infection
Package info
github.com/raneomik/infection-tester-adapter
Type:infection-extension
pkg:composer/raneomik/infection-tester-adapter
Requires
- php: ^8.3
- ext-dom: *
- infection/abstract-testframework-adapter: ^0.5
- infection/include-interceptor: ^1.0
- phpunit/php-code-coverage: ^12.5.8 || ^14.4
- symfony/filesystem: ^6.4 || ^7.4 || ^8.1
- symfony/process: ^6.4 || ^7.4 || ^8.1
Requires (Dev)
- dg/bypass-finals: ^1.11
- infection/infection: ^0.35.8
- nette/tester: ^2.6.2
- nikic/php-parser: ^5.8
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.3
- phpstan/phpstan-phpunit: ^2.1
- phpstan/phpstan-strict-rules: ^2.1
- phpstan/phpstan-webmozart-assert: ^2.0
- phpunit/phpunit: ^12.5.8 || ^13.4
- rector/rector: ^2.7
- thecodingmachine/safe: ^3.4
Suggests
None
Provides
None
Conflicts
- nette/tester: <2.5
Replaces
None
README
Disclaimer: AI agent experiment
chat-gpt5.2 & claude sonnet 4.5 & later 5.5 wrote ~60-75% of this project, by my lack of knowledge on this topic and lack of time to learn... I thought it would be interesting to ask AI "Hey, I discovered this framework, and it comes with its own testing framework. But I love Infection and its metrics to push you to test your tests, and could be cool to add an adapter to it... Are we in ? - yes, Here's your code" (it wasn't this simple, here's some copilot's very verbose journals & reports for french speakers - it's a real mess, sorry, all dev problems seem to be included) and share the result.
The remaining ~20% was based on PhpSpec Adapter and Codeception Adapter. Big shoutout to Maks Rafalko & Infection community for this amazing tool
This package provides the Tester test framework adapter for Infection.
graph TB
Project["Any project that uses Infection"]
Adapter["raneomik/infection-tester-adapter"]
Infection["infection/infection"]
AbstractAdapter["infection/abstract-testframework-adapter<br/>TestFrameworkAdapter"]
OtherAdapters["Other test framework adapters<br/>..."]
Project --> Infection
Project -.-> Adapter
Infection --> AbstractAdapter
Infection --> OtherAdapters
Adapter --> AbstractAdapter
style Adapter fill:#e1f5fe
style AbstractAdapter fill:#f9f9f9
style Infection fill:#f9f9f9
style OtherAdapters fill:#f9f9f9,stroke-dasharray: 5 5
Loading
Requirements
- PHP 8.3+
- nette/tester 2.5+
- PCOV or Xdebug (PCOV is used when both are loaded)
Installation
composer require --dev raneomik/infection-tester-adapter
The adapter is registered automatically through infection/extension-installer (allow the plugin when Composer asks).
Usage
Once installed, you can run Infection:
vendor/bin/infection # optional: --test-framework=tester
Configuration
This adapter works directly with your existing Tester tests, with some limitations:
- Tester provides jUnit.xml and Clover.xml coverage reports, but Infection expects a more complete phpunit-like report. This adapter embeds transformation of Tester's reports & generation during the mutation process, so it is NOT recommended to use
--skip-initial-testswith--coverageoptions (it just results in xpath read/FQCN error, unless you are using a script which does the needed transformation). - Test cases are recommended for a better report result. But seem slower.
- other forms of tests are supported, but need namespaces to be identified by Infection and referenced in report as covering code.
- test files must be named
*Test.php(or*test.php):.phptfiles run, but don't count as covering code. - Tester runs PHP without php.ini (
-n) by default: pass-C,-c <php.ini>,-d <key=value>or-p <php>in--test-framework-options, they are kept for mutant runs too (test paths are not, mutants only run their covering tests). - conflict with files may occur using
--debugoption and result in mutation coverage generation errors. Removing '<configured tmp dir|/tmp>/infection' should fix it.
No additional configuration needed, "Convention over configuration" principle: the only requirement is a tests/bootstrap.php file at your project root.
A minimal infection.json5:
{ "source": { "directories": ["src"] }, "testFramework": "tester" }
For more information on configuring Infection, see the Infection documentation.
Contributing
Contributions are welcome! Open an issue or a pull request; make all runs the CS fixes, static analysis, unit, mutation and e2e tests (make help lists the targets).
License
This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.