I am trying to do unit testing of the module. I need help and information , how to mock or stub a subroutine to test package.
I do not wish to use the module I came across on cpan.
You an mock subs by overriding them in the following way in your test:
no warnings;
local *Foo::bar = sub {
# do stuff
};
use warnings;
You typically want to set a variable to be checked later in your test inside your mock.
(even if I suggest using Test::MockModule, but you explicitly specified to not use it)
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