Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

It's more than just every line. Devel::Cover tests every line, every branch (if/else, etc.), and every conditional (A or B or C).

In my view it's great for reminding one to test edge cases. How often do we write something along the lines of:

some_function() or die; my $variable ||= 42;

How many test suites actually test that the die happens, or test the case where the variable doesn't get set in advance? In using Devel::Cover just a little, I've been more thoughtful about where and how I sprinkle defensive logic and I've also made a point of testing to ensure the defenses actually hold in practice.

-xdg

postscript: my "test that die happens" comment is poorly phrased, probably a bad example, and justly critiqued below by belg4mit. As adrianh and stvn suggest, the coverage test is really testing the or part and whether some_function is falsifiable, not whether die works. If the code coverage tells us that the die phrase is never executed, it's a reminder that we're making an assumption (that some_function might return false), but not testing that assumption. In practice, the coverage test for some_function itself would probably show that there are untested failure cases that explain why some_function never returns false.

Code posted by xdg on PerlMonks is public domain. It has no warranties, express or implied. Posted code may not have been tested. Use at your own risk.


In reply to Re^3: Lessons learned from getting to 100% with Devel::Cover by xdg
in thread Lessons learned from getting to 100% with Devel::Cover by leriksen

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-16 15:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found