DZone
Java Zone
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
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > 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.

Leo Ufimtsev user avatar by
Leo Ufimtsev
·
Oct. 23, 17 · Java Zone · Tutorial
Like (14)
Save
Tweet
111.03K 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, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The End of the Beginning for Apache Cassandra
  • Create a Self-Service Customer Support Chatbot Without Code
  • Why I'm Choosing Pulumi Over Terraform
  • JUnit 5 Tutorial: Nice and Easy [Video]

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo