I was wondering when most people wrote their unit tests, if at all. I usually write tests after writing my initial code to make sure it works like its supposed to. I then fix what is broken.
I have been pretty successful with this method but have been wondering if maybe switching to writing the test first would be advantageous?
whenever possible i try to follow a pure TDD approach:
it is easy to get excited and start coding the feature first, but this often means that you will not think through all of the public interfaces in advance.
EDIT: note that if you write the code first, it is easy to unintentionally write the test to conform to the code, instead of the other way ’round!