Nice introduction. Test::MockObject, by chromatic, is a great module. I'd just like to add that it pays to understand where and when it's important. For example:
my $stuff = Foo::Bar->new( $things );
# do a bunch of things that we want to test
In that example, you're creating a module "Baz", and you want to use Test::MockObject to dummy up a Foo::Bar object. What do you do, though, if $things is not a valid argument to Foo::Bar? There's a good chance that your mock object won't catch this (I've been bitten by this).
Of course, this testing module isn't designed to catch things like that because it's not supposed to. In fact, you could leave the use statement and the constructor out of there and if the rest of the module depends on that object, the mock object may very well still allow the module to work.
Once you have the basic functioning of your code working with this module, then you need to run integration tests without it. Test::MockObject can actually obscure many integration bugs if you're not careful. However, since this module was specifically designed for unit testing, that's not to be taken as criticism. All in all, I give it two thumbs up.
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||