The test-driven development (TDD) methodology advocates the following practice (in that order):
Write tests for the feature you want to implement. Watch the tests fail. Write enough code for the tests to pass. Refactor your code.
I usually don’t care about the order in which the tests and the production code are written. I am used to a more traditional [...]