Two questions about unit tests.
I've been writing unit tests for a while, however they're usually to test classes I already had written. Recently I read an article (mind you an old article) that says you should write unit tests before you begin writing your code.
Does anyone actually follow this methodology? It seems like a good idea on paper, but in practice is it?
- Should you write unit tests to see how your method handles bad/malicious input? Obviously you would want to write tests against functions which are specifically meant to handle "user" input to see how it handles bad/malicious input, but what about functions which should never have this type of input passed to them? At what point do you draw the line?