So my question is, do I remove that extra test so I get to 100% or just leave it in and live with 98.5%?

To start with, you don't need to get 100%. Anything is better than nothing, and anything over 90% should be acceptable as long as you know where you are loosing that other couple of %s. There has been some discussion on the perl-qa list about this in the last month of so, and even Paul Johnson (the author of Devel::Cover) has said, that 100% is alot of times an unreasonable/unreachable goal. Branch and Conditional coverage are notoriously difficult to get 100% on, and things like

my $class = ref($_class) || $_class;
which are very common perl idioms, tend to not get tested (and really dont need to be). Unless your pointy haired boss is breathing down your neck to get 100%, I would be happy with 98.5%. And if your boss really insists, then write the silly/extra/redundant tests to get that 100%, as its no more silly than insisting on that 100%.
As far as I can tell, theres no possible way for this to happen....
Sometimes, this is what Devel::Cover is best at. Showing you code that you dont actually need. If you can't reach the code to test it, then you likely should delete it as its just wasting opcodes.

However, if you don't trust yourself (or others who might touch the code) to not break "step 1" at some point, in a way that "step 2" will fail due to bad input, then leave it in and live with your 98.5%.

This might also be a perfect refactoring opportunity, maybe step 1 and step 2 should/could be different subroutines? Not only would this allow you to test them easily, but it would allow you at a later date to vary the step 1 process to handle different input (to be converted to step2 acceptable output). Just a thought.

-stvn

In reply to Re: Devel::Cover, Testing, 100%?! by stvn
in thread Devel::Cover, Testing, 100%?! by BUU

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.