Revision history for Test::Mockingbird - Advanced mocking library for Perl with support for dependency injection and spies
0.09 Mon May 4 20:22:49 EDT 2026
Bug fixes
- mock_scoped was recording two diagnostic meta layers per call: one of
type 'mock' (emitted by the internal mock() call) and a second of type
'mock_scoped' (pushed explicitly afterwards). diagnose_mocks() therefore
reported depth 2 and a misleading 'mock' entry for every mock_scoped
installation. Fixed by setting local $TYPE = 'mock_scoped' before
delegating to mock(), matching the pattern already used by mock_return,
mock_exception, mock_sequence, and mock_once. Each mock_scoped call now
records exactly one layer of the correct type.
New features
- mock_scoped now accepts multiple method/coderef pairs in a single call,
returning one guard that restores all of them on destruction. Four
argument forms are supported:
Single shorthand (unchanged):
my $g = mock_scoped 'Pkg::method' => sub { ... };
Single longhand (unchanged):
my $g = mock_scoped('Pkg', 'method', sub { ... });
Multi shorthand -- pairs of fully-qualified-name, coderef:
my $g = mock_scoped(
'Pkg::fetch' => sub { ... },
'Other::save' => sub { ... },
);
Multi longhand -- package followed by method/coderef pairs:
my $g = mock_scoped('Pkg',
fetch => sub { ... },
save => sub { ... },
remove => sub { ... },
);
All methods covered by a multi-method guard are restored atomically when
the guard goes out of scope or is explicitly undefed.
- Test::Mockingbird::Guard updated to store a list of fully-qualified
method names rather than a single name, enabling the multi-method
mock_scoped forms above. Single-method behaviour is unchanged.
Tests
- Added t/mock_scoped_multi.t (39 assertions) covering: the meta-layer
bug fix; no-regression checks on both single-method forms; all three
new multi-method forms (multi shorthand, multi longhand two methods,
multi longhand three methods); explicit guard undef; and
diagnose_mocks() state before and after guard destruction.
0.08 Tue Apr 7 18:49:17 EDT 2026
Test::Mockingbird::DESTROY now calls restore_all
0.07 Mon Mar 23 20:15:20 EDT 2026
- Added Test::Mockingbird::TimeTravel:
* Integration to Test::Mockingbird::DeepMock.
* New 'now' plan supporting freeze, travel, advance, rewind.
* Automatic restoration of time state after deep_mock block.
* Deterministic interaction between mocks, spies, and frozen time.
* Added integration test exercising mixed mocking + time travel.
0.06 Fri Mar 20 08:13:40 EDT 2026
- Add restore(): restore all mock layers for a single method target.
- Added diagnose_mocks() and diagnose_mocks_pretty() for structured and
human-readable inspection of active mock layers,
including type and installation location.
0.05 Thu Mar 19 19:05:22 EDT 2026
- DeepMock:
- Added args_eq and args_deeply expectation types for exact and deep argument matching
- Added never expectation type to assert that a spy was not called
- Meets PBP level 5
- Disallow setting a mock to undef
- Add mock_return, mock_exception, and mock_sequence sugar helpers for common mocking patterns.
- Add mock_once: a one-shot mock that restores itself after the first call.
0.04 Thu Mar 19 08:36:23 EDT 2026
- Refactored unmock() to reliably support both shorthand and longhand targets.
- Added DeepMock
0.03 Wed Mar 4 07:29:58 EST 2026
Added shorthand syntax
Added mock_scoped
0.02 Thu Jan 9 08:05:34 EST 2025
Updated spy.t to check that the spied routine is called,
and spying is stopped after restore
More tests
0.01 Wed Jan 8 13:22:13 EST 2025
First draft