You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes when I mock I forgot to mock some subroutine and the unit test calls the real module, causing hard-to-debug tests. It would be nice to have a function that can automatically mock all subroutines of a module with a no-op implementation or sub { die }, so if we forgot to mock a subroutine, the whole test will fail early.
Something like
my $module = Test::MockModule->new('Foo');
$module->auto_mock_all();
Foo->bar(); # dies, or simply no-op
The text was updated successfully, but these errors were encountered:
I'm trying to implement this but I'm stuck at how to get all subroutines of a module, I tried keys %Module:: but sometimes I got things that is not a function. Any tips?
Sometimes when I mock I forgot to mock some subroutine and the unit test calls the real module, causing hard-to-debug tests. It would be nice to have a function that can automatically mock all subroutines of a module with a no-op implementation or
sub { die }
, so if we forgot to mock a subroutine, the whole test will fail early.Something like
The text was updated successfully, but these errors were encountered: