infection/abstract-testframework-adapter
Interfaces and base classes for building Infection test framework adapters. Provides a common abstraction layer to integrate different PHP test runners with Infection’s mutation testing, making adapters consistent, reusable, and easier to implement.
Start by installing the package via Composer:
composer require infection/abstract-testframework-adapter
This package is not meant to be used directly by end-users—it’s a dependency for framework-specific Infection adapters (e.g., infection/PHPUnit-adapter). As a developer, you’ll leverage it when building or extending an Infection adapter for a new or modified test framework. The first place to look is the src/ directory—focus on:
TestFrameworkAdapterInterface (core contract)AbstractTestFrameworkAdapter (base implementation)Configuration/ (config utilities)HasSyntaxErrorDetection interface (added in 0.5.0) for handling syntax error output.Your initial use case will involve implementing runTests() and handling standardized results, now with optional syntax error detection via the new interface.
AbstractTestFrameworkAdapter: Extend the base class to avoid reimplementing common logic (e.g., argument building, exit code mapping, temporary file management).TestFrameworkAdapterInterface: Conform to contracts like getName(), getVersion(), and runTests(): iterable|TestResult[] to ensure compatibility with Infection’s engine.ConfigBuilder for CLI args, TemporaryFileHelper for temp files, and Filter utilities for processing files/test suites.HasSyntaxErrorDetection (new): Implement the optional hasSyntaxError() method to parse and flag syntax errors in test output. Useful for frameworks where syntax failures (e.g., ParseError) should be treated distinctly from test failures.infection.json via the testFramework config key and wire it through Infection’s DI container.mapExitCode() to handle framework-specific codes (e.g., syntax errors vs. test failures).HasSyntaxErrorDetection interface expects you to parse output for syntax errors (e.g., ParseError in PHPUnit). Return true in hasSyntaxError() if the test output contains such errors. Note: This is optional but recommended for frameworks where syntax failures are critical.getVersion() and branch parsing logic accordingly. For syntax errors, check for framework-specific patterns (e.g., ParseError in PHPUnit’s JSON output).AbstractTestFrameworkAdapter::getTests() as the canonical reference for output expectations.getAdditionalArguments() for framework-specific CLI flags and createProcess() to inject custom process behavior (e.g., env vars, timeouts). For syntax errors, extend hasSyntaxError() to handle edge cases (e.g., suppressed errors).How can I help you explore Laravel packages today?