Mocking LWP::UserAgent properly

This is an update to an earlier post I wrote about the adventures I had in creating and using a mock LWP::UserAgent for testing purposes. The ever-vigilant mst overheard a conversation on the same topic, and jumped in. He pointed out that Test::MockObject (and everything using it) overrides UNIVERSAL::isa in a way that hides bugs. Because it can hide bugs, it is definitely not safe to use in a test suite, where you’re trying to uncover bugs.

The bottom line

Instead of following my earlier advice, use Test::LWP::UserAgent, a new module which avoids Test::MockObject and offers a better interface (in particular, the nonsense with subtypes is no longer needed) for creating and using mock LWP::UserAgent objects.