I don't have a precise answer, but saw Chad Granum's YAPC 2016 presentation on Test2, and saw there are some flexible tools for mocking that may be worth investigating. Chad showed a link to the Test2 manual, but it was too fine a font to read on the video. Perhaps someone else can include it.