This page explains you the difference between:
Basically, you need to look at the inversion of control principle:
With a library, it's easy to test your code whereas within a framework, the framework should provide a test feature.
1)