简体   繁体   中英

PHPUnit, Code Coverage, xdebug and html reports

Well, I have a problem trying to setup code coverage reports. First thing I had to do was to install xdebug, I did it, and it worked...Well, actually, instead of showing me the coverage of my test code it shows a couple of files inside of PHPUnit module's directory, and some other strange files from framework's system directory such as:

C:/xampp/htdocs/.../src/modules/Unittest/classes/kohana/unittest/helpers.php
C:/xampp/htdocs/.../src/modules/Unittest/classes/unittest/helpers.php
C:/xampp/htdocs/.../src/system/classes/kohana/config.php

Another problem is that the coverage files that should be html reports which are created with every "phpunit" command executed are always saved to the C:// directory. I tried to change it in xdebug settings in php.ini, but none worked.

Does anybody knows what could be the reason?
I'm using Jenkins if this is any helpful info.
And please tell me if you need more info.

Thanks.

 C:/xampp/htdocs/.../src/modules/Unittest/classes/kohana/unittest/helpers.php
 C:/xampp/htdocs/.../src/modules/Unittest/classes/unittest/helpers.php
 C:/xampp/htdocs/.../src/system/classes/kohana/config.php

These files seem like test helpers and config. PHPUnit will generate code coverage for every file that doesn't just contain unit tests.

If you don't want these files to show up use excludes in your phpunit.xml file

  <whitelist addUncoveredFilesFromWhitelist="true">
    <directory suffix=".php">src</directory>
    <exclude>
      <directory suffix=".php">tests</directory>
      <file>src/system/classes/kohana/config.php</file>
    </exclude>
  </whitelist>

To answer the second question we'd need to see how you run the tests and your phpunit.xml.

For later please consider putting only one answerable question per "question" you open up. As this is not a forum and each question should be one solved issue it's easier to get answers for your stuff :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM