I tend to write unit tests for core functions/modules as I develop them. It helps me create an API and to think about it's use/documentation. I also write tests whenever I come across a non trivial bug: write a test to create the bug, fix the bug, prove it by passing test. I haven't gone the whole hog and employed test driven development. I think all types of testing matter most once deployed. You need to prevent your customers 'testing' your app :-) Of course retro fitting tests is often a waste of time as your perspective isn't so clear.
There is always a balancing act between prefect text book engineering and just making some money!
There is always a balancing act between prefect text book engineering and just making some money!