Thursday, June 7, 2018

Java Code Coverage IntelliJ and Eclipse


Java Code Coverage using IDE

This article is an effort to improve the JUnit Test code coverage. Following snapshots covers the steps to integrate code coverage tools with IDE on local machine.
IntelliJ
  1. Make sure coverage plugin is installed in IntelliJ
  2. And the Coverage view is enabled

  3. Configure the Junit in run configuration


  4. Following is an example for hraction module
    1. Configuration tab

    2. Code coverage tab, You may select the coverage runner from dropdown. Options are Jacoco and IntelliJ IDEA

  5. Click on run with coverage

  6. To see the coverage results select the class file on which code coverage is to be run and execute the below command:




Eclipse
  1. Install Jacoco Code coverage plugin

  2. Open the Coverage configuration

  3. Configure the details as per your need

  4. Select the project and run coverage from tool window

  5. You get the coverage data in below format




No comments:

Post a Comment