Your brain tends to do better if you can stay focused on your task for consecutive, though not indefinite, periods of time. This varies from person to person, and depends on how long a build/run/test takes. But the challenge for many is that 'break' often becomes a context switch, a potential loss of momentum, and worse may open me up to a distraction rather than a productive use of my time.

For me, personally, a better break is one I define on my calendar and helps me defragment my brain for a short period of time before re-engaging.

I recommend investigating the concept of 'deep work' and drawing your own conclusions.