evankford/pest-plugin-mutate-lines

Scope Pest mutation testing to changed lines (--mutate-diff) or explicit line ranges (--mutate-lines).
13
Install
composer require evankford/pest-plugin-mutate-lines
Latest Version:v0.1.1
PHP:^8.4
License:MIT
Last Updated:Oct 15, 2026
Links: GitHub  ·  Packagist
Maintainer: evankford

Pest Plugin: Mutate Lines

Scope Pest mutation testing to the lines you actually changed, instead of every line of every covered class.

Long-lived classes can take minutes to mutate in full. While you iterate on one method, this plugin limits --mutate to your diff or to explicit line ranges.

Installation

composer require evankford/pest-plugin-mutate-lines --dev

Pest discovers the plugin automatically. Requires Pest 5 and pestphp/pest-plugin-mutate 5.

Usage

# Lines changed vs HEAD: uncommitted edits plus every line of untracked .php files
vendor/bin/pest --mutate --mutate-diff tests/Unit/FooTest.php

# Lines changed since the merge base with a ref (committed + uncommitted)
vendor/bin/pest --mutate --mutate-diff=origin/main tests/Unit/FooTest.php

# Explicit ranges, relative to the project root; repeat the flag for more files
vendor/bin/pest --mutate --mutate-lines=src/Foo.php:12,40-55 tests/Unit/FooTest.php

--mutate-diff and --mutate-lines can be combined; the selections are merged.

Notes

  • Flags need =. --mutate-lines src/Foo.php:12 (with a space) falls through to PHPUnit and errors.
  • Selected lines are intersected with what --mutate would normally mutate (your covers() / --class / --path scope), never widened.
  • Nodes that span a selected line (e.g. the enclosing method's visibility) are mutated too. Pure deletions select nothing.
  • The INFO Mutating only N selected lines across M files banner confirms the flag took effect. 0 Mutations means none of the selected lines belong to the classes being mutated.
  • A scoped 100% says nothing about the untouched lines of a class. Iterate with these flags, then run one plain --mutate before calling the work done.

Compatibility

LineRangeMutationGenerator extends pest-plugin-mutate's internal MutationGenerator, so a minor release of that package could break this one. CI runs against both the lowest and the latest supported versions.

Development

composer test         # rector, pint, phpstan, unit tests
composer test:mutate  # mutation tests (needs pcov or xdebug), must stay at 100%

License

MIT. See LICENSE.md.

Related Packages

pestphp/pest-plugin-mutate

Mutates your code to find untested cases

59,051,436 46
pestphp/pest-plugin-agent

AI agent verification plugin for Pest

717,021 7
nekofar/pest-plugin-mock-client

Pest Plugin for Mock HTTP client

22 1
quadraecom/pest-plugin-selectors

Add CSS selector-based testing capabilities to Pest

2,035 1

Version History

Version Released PHP License
v0.1.1 ^8.4 MIT
v0.1.0 ^8.4 MIT