unit testing - perl mocking is there a way to mock $? -
i using test::mockmodule test perl module. 1 of phone call require checking status of $? error code , programme checks it.
how can mock result of $?
code under test below.
my $result = ccutil::cleartool($cmd); if ( $? != 0 ) { confess "stream $stream not found( $result) "; } the api returns string , sets $? checking status.
normal method calls , homecoming values changed using below
my $module = test::mockmodule->new('ccutil'); $mockmodule->mock(cleartool => sub {return 'stream not found'}); the method phone call mocked. not value of -- $?
my $module = test::mockmodule->new('ccutil'); $mockmodule->mock(cleartool => sub { $? = 0x0100; homecoming 'stream not found' });
perl unit-testing mocking
No comments:
Post a Comment