Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Testing -- making a new constructor behave differently for one package

by tj_thompson (Monk)
on Jan 30, 2012 at 18:58 UTC ( #950825=note: print w/ replies, xml ) Need Help??


in reply to Re: Testing -- making a new constructor behave differently for one package
in thread Testing -- making a new constructor behave differently for one package

Yeah, but that assumes that when you're designing Foo you want to hard code this test hook into the class. This seems like a bad plan for a number of reasons. Problem here is you need to test Foo after it's been created.

I actually tried to figure out how to add a method modifier from the Foo meta class so it only existed during my test case, but couldn't quite figure how to do that yet...so this was my plan B...but I eventually went to plan C after realizing (thanks Chromatic) I could hijack the accessor to the class name. That turned out to be far simpler :)


Comment on Re^2: Testing -- making a new constructor behave differently for one package
Re^3: Testing -- making a new constructor behave differently for one package
by tobyink (Abbot) on Jan 30, 2012 at 22:32 UTC

    Why does it assume that? The around new => sub {}; stuff doesn't need to be in the same file where the Foo class is defined. I'd probably put it in the ".t" file.

      That actually never occurred to me. Excellent point and it would have been another way to accomplish my objective. Thanks for the insight.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2014-09-20 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (159 votes), past polls