dimanche 6 décembre 2020

PHPUnit marks 'use Trait' lines as 'not executed'

I am using PHPUnit 9.3.8 and PHP 7.3. When I run --coverage-html for my classes, the result page shows that lines use SomeTrait; are marked as 'Not executed'. For example:

class DeleteQueryBuilder extends AbstractQueryBuilder {
    
    use WhereTrait;

    use LimitTrait;

    public function build():IQuery {
        //some code here...
    }
}

And in this case lines 'use WhereTrait;' and 'use LimitTrait' are marked as 'Not Executed'(the result page states that 4/6 lines are covered, 4 lines being the lines in the build method; the use lines are marked as red which also means that they are not executed). What could be the reason for that and how can I solve this problem? Of course, this is a minor issue, but I am not comfortable with having 66.67% coverage for no clear reason.

Thanks a lot in advance for your help.

Aucun commentaire:

Enregistrer un commentaire