In the previous answers Code coverage has been explained well . I am just adding some knowledge related to tools if your are working on iOS
and OSX
platforms, Xcode provides the facility to test and monitor code coverage.
Reference Links:
https://medium.com/zendesk-engineering/code-coverage-and-xcode-6b2fb8756a51
Both are helpful links for learning and exploring code coverage with Xcode.