SyntaxStudy
Sign Up
PHP Intermediate 3 min read

Code Coverage

Code Coverage

Coverage reports show which lines are executed by tests. Run with Xdebug or PCOV — aim for meaningful coverage, not 100% for its own sake.

Example
# Run with coverage (requires Xdebug or PCOV)
./vendor/bin/phpunit --coverage-html coverage/
php artisan test --coverage
# Coverage configuration in phpunit.xml
<coverage>
    <include>
        <directory>app/</directory>
    </include>
</coverage>
# Pest coverage
./vendor/bin/pest --coverage --min=80
Pro Tip

Focus coverage on business logic and edge cases — trivial getters and framework glue rarely need it.