testo/bridge-infection
Infection mutation testing bridge for Testo. Lets Infection run Testo as the test framework, mapping per-mutant execution to Testo’s --filter/--teamcity options and using PHPUnit-style coverage XML from testo/codecov. Auto-discovered via extension-installer.
Prerequisites:
composer require --dev testo/testo
testo/codecov for coverage XML generation:
composer require --dev testo/codecov
testo.yaml (if not already done).Install the Bridge:
composer require --dev testo/bridge-infection
Configure Infection:
Update infection.json to specify Testo as the test framework:
{
"testFramework": "testo",
"include": ["tests/"],
"threads": 4,
"minimumDetection": 95,
"timeLimit": 60
}
First Run: Execute Infection to verify integration:
vendor/bin/infection
infection/extension-installer.--teamcity and --filter flags are respected in mutant runs.testo.yaml includes coverage settings for testo/codecov.Identify Weak Tests in a Laravel Feature:
vendor/bin/infection --filter="Feature\AuthTest"
--teamcity output in CI for detailed reporting:
vendor/bin/infection --teamcity | tee results.xml
# Run Infection with Testo (auto-discovered)
vendor/bin/infection
# Target specific tests
vendor/bin/infection --filter="Feature\UserTest"
# Limit mutants to a single file
vendor/bin/infection --include="tests/Feature/UserControllerTest.php"
jobs:
mutation-testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- run: composer install
- run: vendor/bin/infection --teamcity --threads=2
Leverage Infection’s threading to reduce runtime:
vendor/bin/infection --threads=4 --timeLimit=120
vendor/bin/infection --filter="Unit\Service\*" --min-detection=90
--filter to isolate problematic test files.testo/codecov generates XML coverage reports:
# testo.yaml
coverage:
driver: xdebug
output: build/coverage.xml
--filter to exclude transaction-heavy tests if needed.testo.yaml for autoload paths).testo/codecov generates PHPUnit-style XML.infection/include-interceptor is installed (required for Testo’s autoloading).Infection passes Testo’s --filter and --teamcity flags automatically. To add custom flags:
// infection.json
{
"testFramework": "testo",
"testFrameworkOptions": ["--verbose", "--no-progress"]
}
Class 'Testo\Testo' not found.
testo/bridge-infection and testo/testo are installed. Run:
composer require --dev testo/testo testo/bridge-infection
testo/codecov generates valid PHPUnit-style XML. Check:
vendor/bin/testo --coverage --output=build/coverage.xml
<testsuite> and <testcase> nodes.include_interceptor fails to load Testo classes.
infection/include-interceptor (v1+):
composer require --dev infection/include-interceptor
autoload paths are included in testo.yaml.--filter to exclude problematic tests.timeLimit in infection.json.--threads or exclude large test suites with --filter.vendor/bin/infection --verbose
Use --filter to narrow down failing mutants:
vendor/bin/infection --filter="Unit\Service\UserServiceTest"
Clear Infection’s cache if mutants behave inconsistently:
rm -rf .infection
--path Handling--path values to be relative to projectDir. If paths are absolute, add this to infection.json:
{
"projectDir": "/absolute/path/to/project"
}
--format=junit works:
vendor/bin/testo --format=junit > build/test-results.xml
Infection\Strategies\TimeLimit). Track Testo’s roadmap for updates.post-mutation scripts to analyze results:
// infection.json
{
"scripts": {
"post-mutation": "php scripts/analyze-mutants.php"
}
}
--teamcity output to CI tools:
vendor/bin/infection --teamcity | ./node_modules/.bin/junit-report-builder -o results/
Exclude Integration Tests: Mutation testing is slow; exclude heavy integration tests:
// infection.json
{
"exclude": ["tests/Integration/*"]
}
Use Pest for Quick Feedback: If using Pest alongside Testo, prioritize Pest for fast feedback and Testo + Infection for mutation testing.
Monitor Testo’s Roadmap: Follow Testo’s GitHub for updates on Infection support (e.g., Laravel-specific test environments).
Leverage --min-detection:
Start with a lower threshold (e.g., 80) to avoid false positives:
vendor/bin/infection --min-detection=80
How can I help you explore Laravel packages today?