MockObject - reference

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I need fake object to tests. I tried to use Test::MockObject

Example below show my problem:
Fake object $tmp was created by fake xxx->new, but ref is still
"Test::MockObject" and set_xxx dies during checking reference

Filip (Poland)

use Test::MockObject;
use Data::Dumper;

$Mock_ua = Test::MockObject->new;

my $tmp = xxx->new();
my $mytest = mytest->new();


package mytest;

    sub new {
        my $class = shift;
        my $self = {};
        bless ($self, $class);
        return $self;

    sub set_xxx {
        my $this = shift;
        my $foo = shift;
        die "Wrong reference" if (ref $foo ne 'xxx');

Site Timeline