Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Overriding a module that is used by a program I'm testingby belden (Friar) |
on Dec 09, 2010 at 22:06 UTC ( [id://876336]=note: print w/replies, xml ) | Need Help?? |
Test::Resub handles this. We use this extensively in our test suites at work.
In your test:
Probably you'd want to have a single resub ofProc::Background::new up high in your test, so you don't need to keep creating the resub. Test::Resub allows you to capture the arguments that go to your resubbed code. For example, consider this helper function
Not only would it be nice to prevent the test from actually creating sockets, it would be good to know how we're creating those sockets. The test might look like this
Sometimes you might find you want to allow the original code to run, but you want to eavesdrop in on the arguments that get sent in to it. Test::Wiretap handles that. You can have multiple resubs and wiretaps in place for the same subroutine: they'll stack properly and unroll correctly.
In Section
Seekers of Perl Wisdom
|
|