DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 3: Understanding Janus
  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j
  • Introducing Graph Concepts in Java With Eclipse JNoSQL
  • Simplify NoSQL Database Integration in Java With Eclipse JNoSQL 1.1.3

Trending

  • How AI Coding Assistants Are Changing Developer Flow
  • How to Detect Spam Content in Documents Using C#
  • The Third Culture: Blending Teams With Different Management Models
  • Building a Reusable Framework to Standardize API Ingestion in an On-Prem Lakehouse
  1. DZone
  2. Coding
  3. Frameworks
  4. Java Code Coverage in Eclipse

Java Code Coverage in Eclipse

We often think of using code coverage only for testing. In this post, we take a quick look at a new way of making use of such a tool in your Eclipse instance.

By 
Leo Ufimtsev user avatar
Leo Ufimtsev
·
Oct. 23, 17 · Tutorial
Likes (14)
Comment
Save
Tweet
Share
121.0K Views

Join the DZone community and get the full member experience.

Join For Free

People often think that Java code coverage tools are only used for testing. I beg to differ. I was recently investigating a JVM crash issue and had been interested in seeing which lines of code among those that were run could have had an influence on the crash.

To help with this, I used a tool that I recently discovered and have been using ever since called the EclEmma Java code coverage plugin. It’s for Eclipse and it’s free.

It’s very simple and intuitive and has all you would expect from a code coverage tool. With it, you can:

  • See code coverage for a java application that you’ve run (and potentially merge multiple run instances)
  • See code coverage for jUnit tests and maven tests
  • See which classes have which amount of coverage.
  • And more!

To use it, you can either right-click on a class and then find and click Code Coverage > Run As, or you can just hit the Run As Code Coverage button that looks like the regular Run button (shown here):

In the screenshot below, the colors are fairly self-explanatory. The color yellow means that it ran into a conditional (if/select/try) and only executed one branch.

To install EclEmma, just search for ‘eclemma’ in the marketplace:

If you decide to try this plugin out, I recommend you read the EclEmma user guide to get acquainted with all of its features (it’s fairly short, only 15 mins of reading).

Code coverage Java (programming language) Eclipse

Published at DZone with permission of Leo Ufimtsev. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 3: Understanding Janus
  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j
  • Introducing Graph Concepts in Java With Eclipse JNoSQL
  • Simplify NoSQL Database Integration in Java With Eclipse JNoSQL 1.1.3

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook