I found this excellent article today on writing testable code. I find one of the big problems in our organization is that we know we need to test code, and it sounds like a simple thing to do, but it is difficult thing to get your head around.
This article talks about making your code testable. It is important to differentiate between writing unit tests and writing end-to-end tests. An end to end test is a test that acts like the user for your application, and it is good for finding wiring bugs. Unit tests on the other hand, handle much simpler form of bug and a more common form of bug.
I recommend this article for all developers were not currently writing unit tests for all of their code.