$f->override( 'test::function', sub { print 'foo' } ); # Do your testing; $f->restore( 'test::function' );