http://qs321.pair.com?node_id=593827

xdg has asked for the wisdom of the Perl Monks concerning the following question:

I'm looking for suggestions for best practices for testing a web service client. For testing the service, there is Test::WWW::Mechanize and friends, but I want to write tests for the client.

I found Test::HTTP, which provides some handy test functions for HTTP responses, but it seems designed to do "live" testing against a service. For a service with an API key, though, I don't want to package automated tests with a key, or require users to supply one to Makefile.PL.

I suspect I should just use Test::MockObject to mock responses the client gets from calls to LWP.

All of this makes me think that writing tests for the client is going be harder and take longer than writing the client itself, so I'm looking for any suggestions or experiences that people can share for how to make it more painless.

Thanks in advance,

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.