Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by perrin (Chancellor)
on Mar 31, 2004 at 21:54 UTC ( #341438=note: print w/ replies, xml ) Need Help??


in reply to Re: 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)

But most of the redundancy of the tests is actually encapsulated in functions

That sounds fine then.

I do have to disagree that can is not "really calling the interface to my class" though.

It isn't calling the interface. It is calling the can() method which is typically inherited from UNIVERSAL::can(). This will break if you do any sneaky AUTOLOAD stuff. (Sure, you could fix that, but what a waste of time.) It's better to actually call the method you are checking instead.

I suppose that just testing that they are there (can_ok) is good enough. Do you agree?

Yes, for constants. I think it's better to use globals than the subs that the constant pragma creates, but that's a whole other discussion.


Comment on Re: Re: Re: Testaholics Anonymous (or how I learned to stop worrying and love Test::More)
Re: 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:49 UTC
    This will break if you do any sneaky AUTOLOAD stuff.

    Personally I avoid that stuff like the plague, so it wouldn't be an issue in this particular code base. But i see what you are saying.

    -stvn
Re: Re: Re: Re: Testaholics Anonymous (or how I learned to stop worrying and love Test::More)
by chromatic (Archbishop) on Apr 01, 2004 at 01:41 UTC

    At the risk of tempting tilly into posting a top-level meditation in the subject, I disagree that can() is too tricky to get right.

    Granted, many people get it wrong, but the solution is well documented.

    I prefer to test my subs and methods with can_ok() because I prefer the way it documents failure, if things fail. It's also very handy to test exporting, if that's your style.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-10-20 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (72 votes), past polls