http://qs321.pair.com?node_id=341438


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)

Replies are listed 'Best First'.
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.

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