Product
Solutions
Resources
Company
Download Trial Book a Demo

Selenium Code Coverage for Java Web Applications

Generate Selenium code coverage for a web application developed with Java in Eclipse IDE using the RKTracer tool, in 3 simple steps. Enable the RKTracer tool and rebuild the application, test the instrumented application and save the coverage data, then generate the code coverage reports.

This guide shows how to generate Selenium code coverage for a web application developed with Java in Eclipse IDE using the RKTracer tool, with 3 simple steps:

  1. Enable the RKTracer tool and rebuild the application.
  2. Test the instrumented application and save the coverage data.
  3. Generate the code coverage reports.

Ensure that you're able to build the application and run the Selenium tests.

In short

Integrate the RKTracer plugin with Eclipse IDE, turn RKTracer ON from Run, External Tools, run maven clean and maven test, then generate the report from Run, External Tools, RKTracer Report.

Code Coverage tool integration with Eclipse IDE

Integrate the RKTracer tool with Eclipse IDE before you build and run your Selenium tests.

  1. Close all instances of Eclipse IDE.
  2. Open a new command prompt and run the following command to install the RKTracer tool plugin for Eclipse IDE:
command prompt
rktracer -ec -integrate

Once the RKTracer tool is successfully integrated with Eclipse IDE, you can see the RKTracer tool options in the Run menu, under External Tools.

Enable the RKTracer tool

Enable the RKTracer tool from the Eclipse IDE Run menu:

Eclipse IDE
Run > External Tools > RKTracer ON

Rebuild and run selenium tests

Run maven clean and maven test to build the web application and run the Selenium tests. In general, testing can be unit testing or functional testing.

Generate Code Coverage reports

Generate the code coverage reports from the Eclipse IDE Run menu:

Eclipse IDE
Run > External Tools > RKTracer Report

Enable coverage for selected files

Suppose you need code coverage for source files from three different folders, i.e., core, keys, power, and ignore coverage for folders firmware_loader and lockdown. Edit rktracer.config in the RKTracer installation folder and go to the end of the file and add the following information.

rktracer.config
ignore *.java
instrument */power/* */core/* */keys/*
never */firmware_loader/* */lockdown/*
  • ignore *.java ignores all Java source files from instrumentation.
  • instrument instruments source files from the given folders.
  • never ignores the selected folder.

Suppose you need code coverage for selected functions from three different files. Edit rktracer.config in the RKTracer installation folder and go to the end of the file and set the following variables as shown below.

rktracer.config
ignore *.java
instrument *source-file-X.java *source-file-Y.java *source-file-Z.java
function-ignore *
function-instrument fun_X() fun_Y() fun_Z()

Stuck on your build?

Open a support ticket and an engineer who knows your toolchain will help. You get a tracked ticket ID by email.