Devel::Cover recommendations... or maybe not?
Adrian Howard
adrianh at quietstars.com
Sat Mar 17 20:40:39 GMT 2007
On 15 Mar 2007, at 17:16, David Cantrell wrote:
[snip]
> As far as I can tell, this:
>
> use Test::MockObject;
> my $mockedmodule = Test::MockObject->new();
> $mockedmodule->fake_module(
> 'MockedModule',
> new => sub { $mockedmodule },
> randommethod => sub { print 'i like pie' }
> );
> MockedModule->new()->randommethod();
>
> should mumble about pie. Instead, it mumbles:
>
> Un-mocked method 'randommethod()' called at ...
[snip]
I think you want something like...
use Test::MockObject;
my $mock = Test::MockObject->new->
mock( randommethod => sub { print "i like pie\n" } );
$mock->fake_module( 'MockedModule' );
$mock->fake_new( 'MockedModule' );
MockedModule->new->randommethod;
Cheers,
Adrian
More information about the london.pm
mailing list