suppose there is one subroutine exam in one of the PERL module-
sub exam
{
....
....
exit 0;
}
and i want to write test case for this API like-
is('exam',0,"exam subroutine works properly");
but it is not working, because after exit 0, PERL script is coming out.
so my question is how can we mock the behavior of exit?
Try to use the Test::Exit
perl -le 'use Test::More tests => 2; use Test::Exit ; sub s1 { exit $_[0] }; exits_zero( sub{ s1(0)}, q{exit 0}); exits_ok(sub {s1(1)}, q{exit 1}); '
1..2
ok 1 - exit 0
ok 2 - exit 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With