55

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

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

Kiva
  • 9,193
  • 17
  • 62
  • 94
  • 2
    'To prevent your question from being flagged and possibly removed, avoid asking subjective questions where … your answer is provided along with the question, and you expect more answers: “I use ______ for ______, what do you use?”' – esaj Jan 28 '12 at 15:13
  • 27
    It's forbidden to ask advise ? I would like to change my plugin for a better and I can't ask advise ? This post is not a troll, not a spam, what is the problem ? – Kiva Jan 29 '12 at 09:32
  • 2
    http://www.eclemma.org/ Java Code Coverage for Eclipse – oers Jan 29 '12 at 15:39
  • @Kiva I recommend reading the first two items of the [FAQ](http://stackoverflow.com/faq). They can help you understand the kinds of questions which should and should not be asked here. – Andrew Barber Jan 31 '12 at 21:34
  • 5
    I tought my question was: software tools commonly used by programmers. Sorry for the misunderstanding – Kiva Feb 02 '12 at 14:22
  • 14
    This sucks that this question is closed as not constructive! :P – PiersyP Jan 09 '13 at 19:29
  • 1
    I use EclEmma, here's the updatesite http://update.eclemma.org/ – Diego Faria Jan 21 '14 at 12:33
  • 1
    **EclEmma**: Java Code Coverage for Eclipse – user3601784 Oct 11 '14 at 20:11

3 Answers3

35

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.


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.

Community
  • 1
  • 1
ziesemer
  • 27,712
  • 8
  • 86
  • 94
  • eCobertura Looks nice, although Eclemma has nicer coverage reports within Eclipse (you can apply filters instead of always showing all classes and packages). – Joey Sep 10 '13 at 07:22
  • eclemma is better at displaying coverage report. It also support to configure exclude source directory. This is needed when your unit test code and target code are placed in the same package. – Houcheng Dec 16 '13 at 08:18
  • 1
    Just be cautious that, Eclemma yields 0% coverage results if used along with PowerMock [[SO question](http://stackoverflow.com/questions/23363212/powermock-eclemma-coverage-issue)] – KrishPrabakar Dec 03 '15 at 06:09
5

I like http://codecover.org/

The source highlighting is better than eCobertura, the drill-down is easy to read, selecting test cases is easy, it actually provides statistics for statement, branch, loop and condition coverage ( a lot of plugins only do statement, which is kinda useless ).

We use it at our business and we found it the best plugin by far.

Kane
  • 4,047
  • 2
  • 24
  • 33
  • For what it's worth, I just tried CodeCover with Eclipse Indigo and the whole IDE got stuck in an infinite loop producing error message boxes ("`NullPointerException at org.eclipse.core.internal.runtime.Log.isLoggable(Log.java:101)`"). :( – ZeroOne Dec 14 '12 at 14:54
  • Huh, I'm using Indigo and CodeCover right now (well, today) and I haven't had any problems. I would guess your Eclipse installation is FUBAR if that's happening. – Kane Dec 20 '12 at 20:24
  • Oh, OK, must be just my environment then. – ZeroOne Dec 20 '12 at 22:30
  • gives "A fatal error occured: An error occured when trying to compile the instrumented sources." in my project. not a lot on the forums. looks promising but a bit new. – simbo1905 Feb 23 '13 at 12:59
  • @simbo1905: You're trying to compile something from another project instead of a jar file (I believe). I ran into that problem a few times myself. I find it's better to depend on the jars anyway so that was just another fix it encouraged. – Kane Feb 25 '13 at 13:16
  • FWIW: As soon as I enabled it, I got a collection of errors that a dependency couldn't be compiled (with no further details). Sad face. – Mason Bryant Jul 28 '14 at 17:32
  • There's a change in Luna that broke CodeCover. I actually sent a patch to the maintainer last week and I'm waiting for a response. – Kane Jul 28 '14 at 19:40
3

Coverlipse: http://coverlipse.sourceforge.net/ because it's free

ka3ak
  • 2,435
  • 2
  • 30
  • 57
  • 1
    "Because it's free" is not the best reason as it might also be a steaming pile of shtako. – BenM Feb 28 '14 at 10:01