https://github.com/nigelhorne/test-mockingbird
Advanced mocking library for Perl with support for dependency injection and spies
https://github.com/nigelhorne/test-mockingbird
cpan cpan-module perl perl5
Last synced: 9 months ago
JSON representation
Advanced mocking library for Perl with support for dependency injection and spies
- Host: GitHub
- URL: https://github.com/nigelhorne/test-mockingbird
- Owner: nigelhorne
- License: gpl-2.0
- Created: 2025-01-08T17:10:57.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-14T12:49:59.000Z (about 1 year ago)
- Last Synced: 2025-06-17T18:09:52.313Z (about 1 year ago)
- Topics: cpan, cpan-module, perl, perl5
- Language: Perl
- Homepage: https://metacpan.org/pod/Test::Mockingbird
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
# NAME
Test::Mockingbird - Advanced mocking library for Perl with support for dependency injection and spies
# VERSION
Version 0.02
# SYNOPSIS
use Test::Mockingbird;
# Mocking
Test::Mockingbird::mock('My::Module', 'method', sub { return 'mocked!' });
# Spying
my $spy = Test::Mockingbird::spy('My::Module', 'method');
My::Module::method('arg1', 'arg2');
my @calls = $spy->(); # Get captured calls
# Dependency Injection
Test::Mockingbird::inject('My::Module', 'Dependency', $mock_object);
# Unmocking
Test::Mockingbird::unmock('My::Module', 'method');
# Restore everything
Test::Mockingbird::restore_all();
# DESCRIPTION
Test::Mockingbird provides powerful mocking, spying, and dependency injection capabilities to streamline testing in Perl.
# METHODS
## mock($package, $method, $replacement)
Mocks a method in the specified package.
## unmock($package, $method)
Restores the original method for a mocked method.
## spy($package, $method)
Spies on a method, tracking calls and arguments.
## inject($package, $dependency, $mock\_object)
Injects a mock object for a dependency.
## restore\_all()
Restores all mocked methods and dependencies to their original state.
# SUPPORT
This module is provided as-is without any warranty.
Please report any bugs or feature requests to `bug-test-mockingbird at rt.cpan.org`,
or through the web interface at
[http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Mockingbird](http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Mockingbird).
I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Test::Mockingbird