Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Sunday, April 30, 2006

Free Code Coverage Tools

What is code coverage? When the query "define:code coverage" is run in Google, you will find the following definitions:

  • An analysis method that determines which parts of the software have been executed (covered) by the test case suite and which parts have not been executed and therefore may require additional attention.
    www.testingstandards.co.uk/living_glossary.htm

  • Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested. It is distinct from black box testing methods because it looks at the code directly, rather than other measures such as software functions or object interfaces.
    en.wikipedia.org/wiki/Code_coverage

There are some great tools that will help you to measure the coverage of your code. Some are commercial, some are free. I used to use Clover that was great. I used point beta versions (0.9x) prior Clover went commercial with the release 1.0. My company did not see much value purchasing anything like that as unit testing and XP was not well know at that time. So I was using the last "free" Clover and I was happy as I got all I needed to keep track the code coverage of my unit tests.

With the explosion of open source projects on the web I was hoping that there would be a good free alternative to Clover after all those years. And there is. As a matter of fact there are many. Lets have a look at the free ones.

Good starting point for hunting for free stuff is at java-source.net. For code coverage tools follow this link. That is the one that I used and will cover in more details.

EMMA

EMMA is an open-source toolkit for measuring and reporting Java code coverage. EMMA's main features are:
  • either offline (before they are loaded) or on the fly (using an instrumenting application classloader) instrumentation,

  • coverage types: class, method, line, basic block,

  • stats are aggregated at method, class, package, and "all classes" levels,

  • output report types: plain text, HTML, XML. All report types support drill-down, to a user-controlled detail depth. The HTML report supports source code linking,

  • output reports can highlight items with coverage levels below user-provided thresholds,

  • EMMA is 100% pure Java, has no external library dependencies, and works in any Java 2 JVM (even 1.2.x).

For few sample reports generated by Emma have a look at http://emma.sourceforge.net/samples.html.

Most of my past projects used Ant for builds. Emma offers several components that expose its functionality as an ANT task and a command line tool, which is very convenient. The documentation is very well written and covers all questions that you might have.

There is also a NetBeans plug-in for Emma. Read some doco about it here.

Unfortunately, if you are looking for an Emma plug-in for Eclipse, there isn't one. Well I could not find any easily. If you do find some, please let me know. If you need a plug-in for Eclipse that will give you a code coverage, use Coverclipse .

Happy testing and getting your code coverage reports!


On May 01, 2006 Jeroen van Wilgenburg said:

You should take a look at Cobertura: When Clover went commercial the project was forked into the commercial Clover and open source Cobertura. It works with Ant, Maven2 and commandline. I think the reports of Cobertura are a bit better than Emma's
There is also an into on Getting started with Cobertura written by him.


On September 26, 2006 Marc said:

You may check out this free EMMA integration for Eclipse: EclEmma

Thursday, March 16, 2006

Java Decompiler for Eclipse

I never really used Java decompilators, but recently I needed one. My peer developers used DJ Decompiler. So I got a copy installed on my laptop and there I was - happily decompiling everything I could possibly need to peek at. It's was cool for a while, but more and more I realized I needed something in Eclipse that would do the same job but better. Switching between Eclipse and DJ Decompiler became very tiring so I did a quick search for Java decompiler that integrates with Eclipse.

There is a Java decompiler that I found and which integrates with Eclipse (as a plug-in) very nicely. It basically decompiles the class butycode and shows you the source as java file (quite handy feature). Ladies and gentlemen let me introduce

JADCLIPSE
http://sourceforge.net/projects/jadclipse/

JadClipse is based on JAD decompiler (which is not included in JadClipse). You can obtain JAD from http://www.varaneckas.com/jad.

INSTALLATION

  • Unzip the jadnt158.zip file, no installation is necessary (to e.g. C:\jadnt158)
  • Add JAD_HOME to your env. variables (e.g. JAD_HOME=C:\jadnt158)
  • Add JAD_HOME to your PATH env. variable (e.g. %SystemRoot%\system32;...;C:\apache-ant-1.6.5\bin;%JAD_HOME%)
  • Unzip jadclipse_xx.zip into "plugins" subdirectory of the directory where you installed Eclipse.
  • Restart or start Eclipse.
  • Open any .class file which you don't have source for, it should be automatically decompiled.
  • Eclipse config - You can change path to Jad's executable (with the steps above simple "jad" will do) and temporary directory as needed (Follow Window -> Preferences -> Java -> JadClipse)

CONFIGURATION:

Most of the Jad's configuration options are available from:

Window -> Preferences -> Java -> JadClipse

Refer to Jad documentation for details on those options in case you need more information.

Happy decompiling!

:Dushan


Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.