"be consistent" | |
PerlMonks |
How to use Test::MockModule betterby arc_of_descent (Hermit) |
on Jan 11, 2006 at 13:58 UTC ( [id://522446]=perlquestion: print w/replies, xml ) | Need Help?? |
arc_of_descent has asked for the wisdom of the Perl Monks concerning the following question: Greetings, I recently got my hands dirty with Test::MockModule, and was successfully able to use it. I was just wondering if I'm heading in the right direction though, and would appreciate any comments and suggestions. I have an object, say $obj, and I want to test its login and get_info methods. $obj uses LWP::UserAgent and both the mentioned methods make an HTTP request and expect some reponse. For the sake of simplicity, assume these methods just return the HTTP response code. In the practice of good testing, I'm not relying on an active internet connection, and thus I decided to fake the LWP::UserAgent's request method in my test script. This is how the test script looks like:
Essentially, every method of $obj involves a HTTP request, and in my test script I am mocking LWP::UserAgent's request method and returning some pre-determined data through a hand crafted HTTP::Response object. What I need advice on is:
Thanks for reading.
Back to
Seekers of Perl Wisdom
|
|