Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: RFC Mocking an Accessor with Test::MockObject

by chromatic (Archbishop)
on Aug 16, 2010 at 20:51 UTC ( #855358=note: print w/ replies, xml ) Need Help??


in reply to RFC Mocking an Accessor with Test::MockObject

If I were to write T::MO again, I'd write Test::MockObject::Extends first, then perhaps generalize to T::MO. The less you need to mock, the better your tested API and the more robust your tests.

If you have to mock an accessor, you're probably mocking too much.


Comment on Re: RFC Mocking an Accessor with Test::MockObject
Re^2: RFC Mocking an Accessor with Test::MockObject
by ait (Friar) on Aug 16, 2010 at 23:16 UTC
    Yeah well every case is different IMHO. This test code is for a specific component a relatively complex Catalyst Model (that is modeled as an aggregate), so I wanted to test very specific classes that receive complex objects and Catalyst Model instances as well. Creating the actual objects would have been a real pain and I wanted to write unit tests for every single component. I looked into Test::MockObject::Extends but it was more than I needed (and virtually impossible and useless to instantiate the whole model to test such a small class), so I settled for the solution above.

    Do you think it's worth a tutorial? Is the title appropriate? I could start the article with your caveat above ;-) ("If you have to mock an accessor, you're probably mocking too much.")

      I'm always interested in more testing articles, especially for sites like Perl.com.

        See if this makes any sense to publich on the PM Tutorials and perl.com: ait's scratchpad

        BTW Shouldn't there be a "Testing" section on the Tutorials page?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-09-23 21:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (241 votes), past polls