This is one of the most common questions asked by new
testers. For now I will take the cowardly approach and say, "it
depends". I've read posts from people touting the number of tests they've
written. This is a new metric as if "line count" wasn't already bad
enough. There is a balance here that we are looking for. Just with the line
count.
If your line count is small you're application probably
doesn't do very much and if it is large then your application might be
cumbersome and difficult to maintain. When you don't have many tests your code
is more prone to errors, but if you've written too many tests maintainability
disappears. But wait! Didn't I say earlier that tests make code more
maintainable. Well, yes I did, but if you write too many it becomes difficult
to change the code. If you test every single possible minute little thing in
your application you're going to have a heck of a time changing anything.
When you're writing tests make sure you
have just enough to give yourself confidence that your code is working.
I highly recommend against ever setting code coverage or
test count goals. If you set goals for these you're just creating incentives to
write more tests than is required. Too many tests can create the same problems
as too much code. Why? Because tests are code.