Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse plugin for code coverage [closed]

I search a code coverage plugin for eclipse. My question is simple:

Which plugin do you use with eclipse for code coverage and why ?

like image 546
Kiva Avatar asked Jan 28 '12 14:01

Kiva


People also ask

Why does Eclipse not show code coverage?

Enable code coverage on your project. Right-click your project and select Properties > Code Coverage. Select Enable code coverage. Click OK.

How do I turn off code coverage in Eclipse?

Go to Windows Menu bar > Show View > Other > Type coverage and open it. Click on Coverage. To clear highlightings, click on X or XX icon as per convenience. Excellent Thank you.

How do I get code coverage in Eclipse?

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):

How do I use code coverage plugin in Eclipse?

The plugin can be easily installed from its update site at http://update.eclemma.org/ on any Eclipse installation of version 3.5 or above. It is also available from the Eclipse Marketplace. After you have installed the plugin, you can run your tests using the new Coverage As launch configuration.


1 Answers

Edit (2015) - My current recommendation: EclEmma / JaCoCo.

Not sure why I didn't see this back in January 2012, as there was clearly active development with new versions consistently being reproduced even back then.

I've since become a bit frustrated with Cobertura / eCobertura, as development since seems to have stalled, with support for current Java versions starting to be somewhat lacking.

JaCoCo may have advanced since I last looked at this in 2012 (or I simply missed it entirely, or was looking at EMMA vs. JaCoCo) - but the current version provides excellent support built-in to Eclipse (provided by EclEmma) as well as many other IDEs, support for Apache Maven, Apache Ant, command-line, Java API, and many other third-party integrations. Please refer to the complete list at http://www.eclemma.org/jacoco/trunk/doc/integrations.html .

I am now switching some of my projects over to JaCoCo from Cobertura, and am very impressed by the integration and results - both in Maven reports as well as Eclipse. Not sure about competing solutions, but JaCoCo can even be configured to fail a build if certain thresholds of code coverage are not met.

JaCoCo is specifically documented to support Java class files from version 1.0 all the way through 1.8*.

I find their Mission Statement very respect-worthy.


References / Resources:

Especially as this question has unfortunately been closed, here is a mini-directory of some of the various references and resources that I used in making my decision - and which I encourage everyone here to refer to in order to make their own decisions.

  • https://en.wikipedia.org/wiki/Java_Code_Coverage_Tools - by Wikipedia's nature is more of a "living document", and will hopefully remain updated with any new related tools that may become available.
  • The following should also somewhat fall into the same category of a "living document", but fall under probable bias / conflicts of interest - as each is from the vendor or organization that also produces such a tool:
    • http://www.eclemma.org/resources.html (Provides EclEmma, JaCoCo)
    • https://confluence.atlassian.com/display/CLOVER/Comparison+of+code+coverage+tools (Provides Atlassian Clover)
  • Presumably independent but dated reviews and comparisons:
    • Code Coverage Tools (JaCoCo, Cobertura, Emma) Comparison in Sonar (2012-12-19, Patroklos Papapetrou, onlysoftware.wordpress.com)
    • Eclipse plugin for code coverage (2012-01-28, stackoverflow.com)
    • Test coverage: jaCoCo vs Clover2 (Jakub Kurlenda, 2010-12-28, kurlenda.blogspot.com)
    • Java Code Coverage: Cobertura vs. Emma vs Clover (Tom Borthwick, 2010-10-23, copperykeenclaws.com)
    • Pick your code coverage tool in Sonar 2.2 (2010-08-05, Evgeny Mandrikov, sonarqube.org)
    • In pursuit of code quality: Don't be fooled by the coverage report (Andrew Glover, 2006-01-31, ibm.com)

Previous:

eCobertura.

It does the job, it is free and open-source, it is more up-to-date than EMMA, and it is used by most of the other online open-source projects I'm familiar with. It also integrates very well into Maven - including some rather nice-looking reports.

If you want to consider a commercial product, I'd consider Atlassian's Clover.

like image 86
ziesemer Avatar answered Oct 03 '22 04:10

ziesemer