Determine if function is called in a test using Perl -
i use test::more
i want see if 1 of functions called or not. there 2 scenarios have: 1 not call function, other will. function not mocked out, want see if called or not.
something like:
my $called; $orig_function = \&yourpackage::yourfunction; { no warnings 'redefine'; *yourpackage::yourfunction = sub { ++$called; goto &$orig_function }; } # code may or may not call yourfunction here ok($called, 'function called');
Comments
Post a Comment