3 ms·
Depends. If it's a bug or a new feature built on top of code that is already tested, then I will write the tests because they fit nicely into already existing t
by why-el 7y ago
Depends. If it's a bug or a new feature built on top of code that is already tested, then I will write the tests because they fit nicely into already existing testing infrastructure. The test therefore "proves" the bug, and the fix eliminates it.
For outright new code (think new objects, new API, and so on), I tend not to write the tests first because they become a cognitive load that affects my early design choices. In other words, I am now writing code to make the tests pass, and have to exert effort not to do that.