They are related in that quality code is code that is both correct now and can easily be made correct when things change--and things always change. Unit tests are what enable correctness in the future.
Or more like, you write unit tests even if no one asked you to.