Overview :
In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite. A program with high code coverage has been more thoroughly tested and has a lower chance of containing software bugs than a program with low code coverage.
In this article we will see how we can generate code coverage report using tools in eclipse . There are number of tools for eclipse that we can use to generate code coverage report :
EclEmma :
In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite. A program with high code coverage has been more thoroughly tested and has a lower chance of containing software bugs than a program with low code coverage.
In this article we will see how we can generate code coverage report using tools in eclipse . There are number of tools for eclipse that we can use to generate code coverage report :
EclEmma :
EclEmma is a free Java code coverage tool for Eclipse, available under the Eclipse Public License. It brings code coverage analysis directly into the Eclipse workbench:
- Fast develop/test cycle: Launches from within the workbench like JUnit test runs can directly be analyzed for code coverage.
- Rich coverage analysis: Coverage results are immediately summarized and highlighted in the Java source code editors.
- Non-invasive: EclEmma does not require modifying your projects or performing any other setup.
How to install EclEmma :
There are number of ways we can install EclEmma to eclipse but in this article we will see how to install EclEmma using update site. The steps are very easy :
use the following update site url in the ellipse install dialog
http://update.eclemma.org/ and follow the instruction
Help >> Install New Software
After successfully installing the EclEmma eclipse plugin ; now it is time to see the coverage report:
Right client on project and click Coverage As > JUnit Test
Running the above command execute all the JUnit test cases and generate Code Coverage report in the coverage view:
if you cannot see the find it from Window >> Show View >> Other..
Export the Report to local disk :
You can export the coverage report for later use:
Click the index.html from the exported files, your will see a coverage report like blow :