Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: Testaholics Anonymous (or how I learned to stop worrying and love Test::More)

by Ovid (Cardinal)
on Mar 31, 2004 at 17:50 UTC ( [id://341357]=note: print w/replies, xml ) Need Help??


in reply to Re: Testaholics Anonymous (or how I learned to stop worrying and love Test::More)
in thread Testaholics Anonymous (or how I learned to stop worrying and love Test::More)

Excellent suggestion. The question of "what do I test?" should always be answered with "what have you tested"? and Devel::Cover does a great job of that. I've wowed coworkers with its HTML output :)

<malden type="karl">Devel::Cover. Don't leave home without it.</malden> (have I just dated myself?)

Cheers,
Ovid

New address of my CGI Course.

  • Comment on Re: Re: Testaholics Anonymous (or how I learned to stop worrying and love Test::More)

Replies are listed 'Best First'.
Re: Re: Re: Testaholics Anonymous (or how I learned to stop worrying and love Test::More)
by stvn (Monsignor) on Mar 31, 2004 at 22:56 UTC
    Ovid

    I am actually running some of my tests through Devel::Cover right now, and and something just popped up.

    What about on coverage for things like this:

    return wantarray ? @results : \@results;
    Devel::Cover reports that I have only tested the @results return value branch. Should I test the \@results branch too, or is this being too granular?

    -stvn

      You know, one thing that I forgot to mention, but it's vitally important to remember: if you find out you didn't test something, you might want to ask yourself if you have dead code. In your example, do you ever call that code in scalar context? (well, void context would also exercise that condition, but we'll ignore that) If not, you have dead code. If you do call it in scalar context, why are you overloading the return value? If you don't need to, perhaps this is an opportunity to simplify your code and thereby reduce the chances of bugs.

      Cheers,
      Ovid

      New address of my CGI Course.

      Personally, I think something like that is too trivial to test -- until it breaks. If that's the only thing that Devel::Cover says you've missed, go ahead and toss the test in there if you like. Otherwise, concentrate on the "big ticket items" and only test that if it breaks (or if you feel like it. Some people are happy to test everything).

      Cheers,
      Ovid

      New address of my CGI Course.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://341357]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found