in reply to Automocked objects
I do this by subclassing Test::MockObject...
package Test::AutoMock; use base 'Test::MockObject'; # This is a stripped-down version of some of my own testing # code, so this is untested, but should work... sub dispatch_mocked_method { my $self = $_[0]; my $sub = splice( @_, 1, 1 ); my $subs = Test::MockObject::_subs( $self ); $self->log_call( $sub, @_ ); if ( exists $subs->{ $sub } ) { goto &{ $subs->{ $sub } }; } else { return 1; } }
dispatch_mocked_method is called by Test::MockObject::AUTOLOAD, and carps when you call a method that hasn't been mocked, so if you just replace the carp with a return 1; you get the 'return true unless overridden' behaviour. I also moved the log call outside the if, so that the call log can include both mocked and default method calls.
| We're not surrounded, we're in a target-rich environment! |
|---|
|
|---|