Site icon TestingDocs.com

How to perform code coverage with Eclipse?

Overview

There are many ways to instrument your test automation code and with many tools. The code coverage tool you pick mostly depends on the programming language. In other words, it depends on the language used to write your automation code.

EclEmma : Java Code Coverage(JaCoCo)

EclEmma is a free coverage tool for Eclipse, available under the Eclipse Public License. The tool is non-invasive. It does not require modifying your project files or any instrumentation set up as such.

Steps to Install the plugin

Install EclEmma plugin for Eclipse.
Launch marketplace from your Eclipse menu selects Help >> Eclipse Marketplace.
Search for EclEmma and click on the Go button.
Hit on Install for EclEmma Java Code Coverage.
Follow the steps and instructions in the installation wizard.

You may need to restart Eclipse after the plugin install.

Code Coverage Configuration

Once you restart Eclipse, in the Coverage window, choose the entries for the code coverage analysis scope as shown below:

 

 

The plugin supports many launch types. In this example, I’m using TestNG test launch type. You can use for other launch types like Java application, JUnit test etc.

Run the TestNG tests. Alternatively,  you can run the tests with Coverage As option.

Coverage View

The Coverage view shows all analyzed Java items as shown below. It can be opened from the Window >> Show View >> Other… >> Java category menu.

 

 

The tool also supports export of coverage sessions in many formats, like HTML, XML, CSV etc.

Exit mobile version