PHPUnit 和 Xdebug 对于抽象类的覆盖率始终为 0%。

huangapple go评论53阅读模式
英文:

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%."

"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
英文:

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%.

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

答案1

得分: 0

"-dauto_prepend_file=xdebug_filter.php"

请移除此部分,因为phpunit.xml.dist文件已经提供了代码覆盖率目录。

英文:

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.

huangapple
  • 本文由 发表于 2023年4月11日 06:01:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75981058.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定