Excluding parts of PHP code from code coverage report

A funny thing happened to me the other day when i noticed a new operator (adnotation) supported by php unit.

So there apparently is a way to ignore parts of the PHP code from code coverage report.

If you put comments like below around some code it wont be counted at all during code coverage.

// @codeCoverageIgnoreStart
echo 'some code here';
// @codeCoverageIgnoreEnd 

First i thought ... ok great i can ignore this annoying bit of code that is hardcoded and cant be really tested as does not depend on any functionality and only makes sure there was no coding error introduced. But then i started thinking ... where should this end? i can actually get myself into a lot of trouble ignoring bits of code here and there. Not only i wont test them any more but i wont even know that i should.

So to summarize i would advise not to use those operators at all. If you know scenario when its really useful and should be used let me know. Im actually interested in applications of it.

Comments

Post new comment

Image CAPTCHA

About the author

Artur Ejsmont

Hi, my name is Artur Ejsmont,
welcome to my blog.

I am a passionate software engineer living in Sydney and working for Yahoo! Drop me a line or leave a comment.

Enjoy!