shipmonk/coverage-guard
Enforce code coverage in CI by targeting core functionality instead of percentages. Legacy-friendly and extensible, it lets you require coverage only for chosen methods and, with a patch, only for new code. Lightweight and easy to start.
Config::addExecutableLineExcluder()IgnoreThrowNewExceptionLineExcluder allows excluding e.g. all throw new LogicException(...) linescheck and patch-coverage commandscheck output// coverage-guard.php
use ShipMonk\CoverageGuard\Config;
use ShipMonk\CoverageGuard\Excluder\IgnoreThrowNewExceptionLineExcluder;
$config = new Config();
$config->addExecutableLineExcluder(new IgnoreThrowNewExceptionLineExcluder([
LogicException::class,
]));
return $config;
CodeBlock::getCoveragePercentage() returns 100% when there are no executable lines (#67)
// coverage-guard.php
use ShipMonk\CoverageGuard\Config;
use ShipMonk\CoverageGuard\Rule\EnforceCoverageForMethodsRule;
$config = new Config();
$config->addRule(new EnforceCoverageForMethodsRule(
requiredCoveragePercentage: 50,
minExecutableLines: 5,
));
return $config;
# Run tests, collect coverage, generate report:
XDEBUG_MODE=coverage vendor/bin/phpunit tests --coverage-filter src --coverage-clover clover.xml
# Verify coverage:
vendor/bin/coverage-guard check clover.xml
How can I help you explore Laravel packages today?