XP is just a number | |
PerlMonks |
Re: When 100% Code Coverage Backfiresby xdg (Monsignor) |
on Mar 26, 2007 at 12:35 UTC ( [id://606567]=note: print w/replies, xml ) | Need Help?? |
by changing my code to get 100% code coverage Isn't the point of coverage to change your tests to increase coverage? Changing your logic for the sake of coverage seems backwards. (Note -- I'm not talking about changing layout of conditionals so that Devel::Cover can follow the logic.) What your example does demonstrate is how seeking 100% coverage can help uncover faulty assumptions in either the requirements or the underlying code. Using something like Carp::Assert or something similar might help here I like that for clarity of intent, but of course, it's only hiding the lack of coverage of the failure of the assertion. Your assert line of code will be "covered", but the underlying logic won't. Nevertheless, if I had to sum up your post, it would this: Conditionals or branches that can't be covered because they always should be true (or false) should be converted into assertions instead. And that does sound like good advice. ++ -xdg Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In Section
Meditations
|
|