Tapestry Training -- From The Source

Let me help you get your team up to speed in Tapestry ... fast. Visit howardlewisship.com for details on training, mentoring and support!

Wednesday, May 16, 2007

Free and Excellent Code Coverage for Eclipse

The EMMA plugin for Eclipse is my latest addition to the "can't live without it" category. It allows you to run applications and test suites from within Eclipse and gather code coverage ... better yet, that code coverage data is shown visibly in your code, much as it is in an HTML Cobertura report.

The plugin is slick, fast, easy and non-intrusive.

The one thing you do need to do is split your output directories, so that production code goes into bin, and test code goes into test-bin; this allows you to turn off coverage information for your test classes, and just gather

Of course, IDEA also has code coverage, based on EMMA, built right in.

11 comments:

Jesse Kuhnert said...

I had always wondered (not enough to try) what that tab was all about in idea....

Thanks.

Titi Wangsa said...

i think eclipse tptp has a line coverage tool. but.. it still spits out errors when using java generics.

Hugo Palma said...

I never used the EMMA Eclipse plugin, but from the screenshot i seem to prefer the IDEA implementation better. The line coverage in the editor is much cleaner as it doesn't use background colours and it shows the coverage statistics right beside the project structure so you don't have to open yet another tab to see them.

Then again, i've used IDEA for about 5 years now so i might be just a little too used to the IDEA way of doing things......

Ben Tomasini said...

I have been an dedicated Emacs user now for years. I have been resisting switching to Eclipse. This feature is probably going to push me over the edge. This kind of immediate feedback is very valuable.

Jesse Kuhnert said...

Ben,

As a fellow dedicated emacs user let me tell you know that you will hate eclipse. You may be so distracted by all the new GUI things happening that you don't notice that your keyboard has been replaced by your mouse. ...

Use idea, it loves your keyboard too.

Ben Tomasini said...

Jesse,

My hands were already aching today from having to use that infernal mouse. I will try Idea. Thanks for the advice.

alvaro said...

hi howard, we been thankful, for you work, this help us many. i am looking in which way can help to tapestry.

thanks for all.
bye.

Tim said...

Howard,

Have you had any luck using this against tests where the method under test is using Javassist?

I've got some Hivemind services being
generated with Javassist and the Emma plugin doesn't work due to what seems like a battle between byte code generators.

If I instrument the code in place with the Emma plugin, everything seems ok, but that makes working difficult since I need to do a build clean after every coverage run.

I know you generate a bunch of code in Hivemind so was wondering if you've seen the same issue?

Howard said...

I've noticed the same thing; inconsistent coverage of POJO code that's been instrumented via Javassist (that is, T5 component classes).

So I end up using EMMA inside Eclipse and Corbetura from the command line (via Maven) and getting different results. That's not ideal, but the big picture is that the component code is a small portion of Tapestry and I get reasonably accurate numbers for everything else.

Massimo said...

Has been lost my comment about aptana?

Anyway... Speaking about Eclipse plugins worth a mention, i would like to note the availability of aptana plugin whch helps html/css/js development a lot.

I did discover it only recently.

cloadsun said...

The EMMA tool (with or without EclEmma plugin) incorrectly reports lines of coverage when using Tapestry 5 PageTester between calls to clickSubmit, clickLink. Only last tests get recorded...