in reply to Re: Testing procedure: how to mock?
in thread Testing procedure: how to mock?
In addition, you could post some of your Test::MockObject or Test::MockModule code, and possibly someone could help you with getting it to work.Ask, and ye shall receive. :)
Thanks in advance,============== Foo.pm ============== package Foo; use strict; require Exporter; our @ISA = qw(Exporter); our %EXPORT_TAGS = ( 'all' => [ qw( foo ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our $VERSION = '0.01'; sub foo { die "This is being called from Foo\n"; } 1; __END__ ============== Bar.pm ============== package Bar; use strict; use Foo qw(foo); our $VERSION = '0.01'; sub new { my ($class) = @_; my $self = []; bless($self, $class); } sub bar { my ($self) = shift; foo(); } 1; __END__ ============== Baz.pl ============== use strict; use warnings; use Test::MockModule; use Bar; { my $mock = Test::MockModule->new('Foo'); $mock->mock('foo', sub {print "Successfully mocked!\n";}); my $bar = Bar->new(); $bar->bar(); }
thor
Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Testing procedure: how to mock?
by stvn (Monsignor) on Sep 27, 2005 at 07:11 UTC |