NAME
Test::Mock::Simple - A simple way to mock out parts of or a whole module.
SYNOPSIS
use Test::Mock::Simple;
my $mock = Test::Mock::Simple->new(module => 'Module::To::Be::Mocked');
$mock->it(add => sub { return mocked_add_method(@_); });
DESCRIPTION
This is a simple method of overriding any number of methods for a give object/class.
Can be used directly in test (or any) files, but best practice (IMHO) is to create a 'Mock' module and using it instead of directly using the module in your tests.
Why another Mock module? I needed something simple with no bells or whistles that only overrode certain methods of a given module. It's more work, but there aren't any conflicts.
Methods
- new
-
Create a new mock simple object.
- module
-
The name of the module that is being mocked. The module will be loaded first so that when you get around to mocking things they will override the module.
- it
-
This allows you to specify a new method (subroutine) that will override the existing one.
The reason for the strange naming convention is because I like the way that '$mock->it(...)' reads.
AUTHOR
Erik Tank, <tank@jundy.com<gt>
COPYRIGHT AND LICENSE
Copyright (C) 2013 by Erik Tank
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.