I was getting a strange smearing effect when I tried to scroll in the main view of my application’s window.
I knew my content-drawing routines were being invoked correctly. I knew that the effect seemed to be happening somewhere in the depths of Cocoa, not in my code. But that’s all I knew.
Turns out, it’s because I was setting my view frames to fractional values (they’re floats, after all), but my content engine was still drawing things per integer coordinates.
This is the kind of thing that unit testing won’t help.
My goal was “make resizing the window and then scrolling through the main view work.” Can’t write a test for that because “work” means “look right,” and you can’t test for that when you don’t know how to make it look right yet.
It’s one part experimenting and one part perseverance and one part lightbulb going off after things go wrong.
And I find myself working through these kinds of issues a lot.
Anyone who says “Always write your tests first” can stick that in their pipe and smoke it.