This would make a great interview question, wouldn't it? Interestingly, over the course of about 10 recent interviews for jobs that said on their listing that they want applicants to know TDD, nobody has asked that to me.
For me, in practice, I usually write tests along with the section of code I'm working on at the time. I'll typically write out a stub or mock for the test first, then the actual code and then fill out the test.
In some cases where I'm not sure about the direction the end code will take, I'll do the code first, filling in the test as I go. For example, I'm not sure if an algorithm or design is the right solution to the problem so I'll experiment with the code before fully building out the tests.
Sometimes, I'll have a really good idea of where the code is going, for example, working with the output from a stored procedure. In that case, I'll put together the test first, complete with mocking data.
We’re a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.