Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

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

I know Devel::Cover in fact we've it tied to Hudson continuous integration server to automatically generate coverage report for our app ( Hudson also does perldoc, load testing and profiling using Devel::NYTProf).

The whole point is to avoid becoming obsessed about the 100% number, because it doesn't guarantees you anything. In fact most valuables test cases we have rarely increments the coverage % as they are border cases or special conditions of things that are already covered.

I don't think you have to aim to have 100%, I think you have to aim to have a consistent test suite where critical paths are good covered.

Ideally private methods are not tested directly, but what if you have the following code

sub method_a { ... open(...) or die "First ..."; ... $self->_method_b(); } sub _method_b { ... open(...) or die "Second ..."; $self->_method_c(); } sub _method_c { ... open(...) or die "Third ..."; }

Now you want to test an error condition in the third open so have mock of the open method and depending on the method's caller the open will return true or false, so your mock's code will have something like

if ( $caller eq '_method_c') { return 0; } return 1; }

Indirectly your test code becomes dependent of _method_c (private method), as a rule of thumb the more nested private method calls you have the more complex the test case will become, sometimes it makes sense to test the private method directly.

There is a good article Give me 100% Code Coverage or Give Me Death!


In reply to Re^6: Making open fail by bluescreen
in thread Making open fail by SilasTheMonk

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 learning in the Monastery: (4)
As of 2024-04-19 04:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found