Kent Beck is the man credited with "rediscovering" the Test Driven Development methodology. It's a great way to ensure your code works as expected and it will allow you to catch errors that occur down the track.
Based on Kent Beck's principles, you should:
- Write code as it spews out of your brain
- Do lots of small refactoring rather than big architectural rewrites
- If you are going to change code, add a test first (aka red-green-refactor)
Tip: Read Michael Feather’s book, "Working Effectively with Legacy Code" for some insights into effective unit testing.
Tip: Don't focus on the percentage of code coverage, focus on whether tests will touch the lines of code you care about.