Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PHPunit and xdebug coverage for abstract classes are always 0%

Repository for this concrete issue: goph-R/dynart-coverage-test

The issue is as in the subject: for abstract classes I always get 0% coverage whatever I do.

  • I created a "TheAbstractClass" and a related "TheAbstractClassTest"
  • In the test I had to instantiate the abstract class, so I created a "TheTestableClass" for it and it extends the "TheAbstractClass". I tried this with the PHPUnit’s "createMockForAbstractClass" the same issue happens.

After I run the tests, everything will PASS, but the coverage report for "TheAbstractClass" is 0%, but for "TheConcreteClass" it is 100%.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What I do wrong, how could I have coverage for my abstract classes?

My configuration:

  • Windows 10
  • PHP 7.4.3
  • XDebug 2.8.1
  • PHPUnit 9.6.6

>Solution :

The command line test invocation includes this argument:

-dauto_prepend_file=xdebug_filter.php

Remove this, you don’t need it, as the code coverage directory is already being provided by the phpunit.xml.dist file.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading