Crazy idea: patch-based testing. A patch test includes a git patch that is applied prior to execution. This allows you to inject test-specific code wherever you want, without cluttering the source. Bonus: changing the source breaks the patch, forcing you to update it.
Agreed! But mocking and other forms of injection also alter normal flow. Patches just make it easier to impose more drastic changes. In particular, patching is ideal for mutation testing (e.g. "the output should be wrong if this + is changed to a -").