Use this so that when testing your code you can easily mock how your code talks to other bits of code,
thus making it possible to test your code in isolation,
and without relying on third-party services.

where 'MyApp::Tests::Mocks::EmailSender' pretends to be the real email sending class, only without spamming everyone every time you run the tests. And of course, if you do want to really send email from a test - perhaps you want to do an end-to-end test before releasing - you would do this:

We also provide a way of easily inserting shims that wrap around methods that you have defined.

use Class::Mockable
methods => {
_foo => 'foo',
};

The above will create a _foo sub on your class that by default will call your class's foo() subroutine. This behaviour can be changed by calling the setter function _set_foo (where _foo is your identifier). The default behaviour can be restored by calling _reset_foo (again, where _foo is your identifier).

If you use namespace::autoclean in the same module as this it may "helpfully" delete mocked methods that you create. You may need to explicitly exclude those from namespace::autoclean's list of things to clean.

This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.