Code coverage

We won't discuss it in depth, but code coverage is another important measure used in software engineering. Code coverage measures the degree of code that your test suites cover. The main idea is that the higher the coverage percentage, the more code is covered by tests, so the less likely you are to create undetected bugs and the service should behave as intended. These reports can help developers come up with additional tests or scenarios to increase the coverage percentage.

Test-coverage-related Python packages include coverage, nose, and the more recent nose2, which can provide coverage reports. For example, you can run the following to get a test-coverage analysis report of your Lambda code with nose or nose2:

$ nosetests ...

Get Building Serverless Microservices in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.