8

The whitelist isn't working how I would expect when get code coverage reports. I am using Zend Framework and my Zend files are also in the library directory just like the project quickstart.

I'm running PHPUnit 3.6 from Netbeans 7.0.1

I only really want to see the coverage for the classes for MyLib.

<whitelist>
    <directory suffix=".php">../../library/MyLib</directory>
</whitelist>

But in the report I seem to get a percentage value for several Zend files eg. Zend_Controller_Front, Zend_Loader_Autoloader etc.

Obviously I haven't written any tests for these classes and it is no surprise that I have 0% coverage.

What have I missed?

gawpertron
  • 1,867
  • 3
  • 21
  • 37
  • What is your blacklist? Are you using `addUncoveredFilesFromWhitelist="true"`? And which PHPUnit version are you using? – hakre Dec 07 '11 at 11:56
  • I'm using PHPUnit 3.6, I've tried a blacklist as well but get the same result. Just tried "addUncoveredFilesFromWhitelist" true and false, but still getting Zend coverage – gawpertron Dec 07 '11 at 12:26
  • 2
    Just seeing, please use absolute paths in your XML file and/or ensure those are correctly resolved by using a step-debugger for your phpunit test-runner call (which I think is hard to do in Netbeans). Also ensure that your XML file is loaded. – hakre Dec 07 '11 at 12:48
  • Yes, just noticed that my paths were incorrect and now it's working – gawpertron Dec 07 '11 at 12:54
  • I added it as an answer. – hakre Dec 07 '11 at 12:56

1 Answers1

1

Please use absolute paths in your XML file and/or ensure those are correctly resolved by your phpunit test-runner call. Also ensure that your XML file is loaded.

hakre
  • 193,403
  • 52
  • 435
  • 836
  • 5
    Just to note/make it clear: Relative paths work when used correctly and should be preferred over absolute ones so that the xml file is portable. Good debugging step though – edorian Dec 07 '11 at 14:31
  • With respect this answer is old, it seems incomplete. What is `test-runner` and how did it help solve the problem? – Jason McCreary Apr 16 '15 at 18:05