Most of the time, however, we are creating web apps and things that run at a much higher level of abstraction than the underlying algorithms. We should probably write tests at the same level of abstraction our solution is.
Although, I guess, when you're writing medical software or something for a bank, you should be a bit more strict than when you are making the next best social sharing app.
A guy I know once solved a bug by having a unit test for the md5 function from the standard library of the language at hand ... turns out a specific version was buggy.
Either way, I prefer using integration/functional test. What I care about is that the right output flies in for a certain input. What I don't care about is how. So I don't test for that.
Also, Unit tests must be created before the code they test.
yes they should. It's very helpful to think about how your code will be used before you write it, helps you think it through as well.