Skip to main content

Posts

Showing posts from 2016

Unit Testing and Code Coverage in Python

Unit Test is one of the most important part of development artifacts, which helps to automatically test whatever code we write. Coverage report measures quality of Unit Tests and points out unused/untested code. This tutorial will help to get started with Unit Testing and Coverage report in Python. For this tutorial we will use Eclipse PyDEV as Python IDE and its integrated Coverage plugin to generate Code Coverage report. Environment Setup: Install PyDEV Eclipse Plug-in. PyDEV comes with Code Coverage feature ( Show View - Code Coverage ) which integrates with python module " coverage " Install Coverage module:   # python -m pip install "coverage < 4.0.0" Coverage module higher than version 3.x doesn't work with PyDEV. Coverage report gets generated as binary file under- Workspace\.metadata\.plugins\org.python.pydev.debug\coverage\.coverage Sample Code:  Download sample code from GitHub . This includes a function (under /src ) to get ODD and