The longer the delay between writing some chunk of code, and executing it, the more valuable mental context is lost. I find it way more productive to work in small chunks iteratively, testing as I go along, rather than writing for a long chunk of time, then running tests and figuring out what bugs are making tests fail.