Unit tests prove that individual parts of the code work as supposed to be, therefore ridding a code base of bugs at the very point where they usually arise. They provide a safety net while refactoring for changes not to break existing functionality.