This is a great series of talks on the Google Tech Talks YouTube channel by Miško Hevery.
Why do many developers have difficulty writing unit tests? One reason is that we simply don't know how. Writing tests is just as much a skill as writing code, and knowing what to test and how to test it is something that needs to be learnt by experience. However, another big reason is that our code is hard to test. Miško Hevery takes a look at what it is about code that makes it hard to test, and looks at how to write clean, decoupled code that is easily testable. He covers things like global state, implicit dependencies, how conditionals and new operators can be bad, and many other factors that make writing unit tests much harder work than it should be.
This is a great introduction to these ideas and a must-see for any developer interested in writing better code. It turns out that the things that make code easier to test also make it loosely coupled, easier to maintain, and more aesthetically pleasing.
The following videos are also available as a playlist.
Don't Look for Things!
Global State and Singletons
Inheritance, Polymorphism & Testing
OO Design for Testability
How to Write Clean, Testable Code