Search by

raneomik / infection-tester-adapter

raneomik

Tester Adapter for Infection

Package info

github.com/raneomik/infection-tester-adapter

Type:infection-extension

pkg:composer/raneomik/infection-tester-adapter

Statistics

Installs: 828

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v0.3.3 2026-11-07 04:27 UTC

This package is auto-updated.

Last update: 2026-11-21 09:32:41 UTC


README

Coding Standards Mutation Testing Tests Coverage Status Mutation testing badge

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-tests with --coverage options (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): .phpt files 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 --debug option 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.