That is part of the reason I write in blocks.

Write a block test a block.

Then stack the blocks up when they are all good.