use Test::MockRandom 'Some::Other::Package'; use Some::Other::Package 'pin'; # exports pin() # list of values for rand to use srand( ( (0) x 4, ( oneish() ) x 4 ); # 0,0,0,0,1,1,1,1 is( pin(), '0000', "rand always zero" ); is( pin(), '9999', "rand always almost one");