Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Testing the 3rd party class

  • This is probably not very interesting, just testing an object-oriented module.
use strict;
use warnings;
use Test::More;

use SomeClass;

my $obj = SomeClass->new;
isa_ok $obj, 'SomeClass';

is $obj->name, undef;
is $obj->name('Apple'), 'Apple';
is $obj->name, 'Apple';

is $obj->double(3), 6;

done_testing;
use strict;
use warnings;
use Test::More;

use Mock::Quick qw(qclass);
my $control = qclass(
    -implement => 'SomeClass',
    -with_new => 1,
    -attributes => [ qw(name) ],
    double => 7,
);


my $obj = SomeClass->new;
isa_ok $obj, 'SomeClass';

is $obj->name, undef;
is $obj->name('Apple'), 'Apple';
is $obj->name, 'Apple';

is $obj->double(3), 7;


$control->undefine();

done_testing;