tags:

views:

146

answers:

2

Hi, is it possible to hook up an agent or something to the jvm before starting up an application (or an appserver) and have a report showing how much of the code base in the classpath is actually executed for a given use case ? I want to figure out how much code is left out unexecuted for my simple servlet application running in an appserver which doesn't use many j2ee technologies like JCA, JMS, CMP, etc.

Best regards, Bulent Erdemir

+9  A: 

What you're looking for is a code coverage tool.

For Java, I've had a great deal of success with EMMA. You should be aware that any code coverage tool is likely to affect performance significantly - typically it's used for unit testing, to check that your unit tests hit appropriate parts of your code. You could use it for a test run of a web app as well though - I'd just recommend against using it for the production deployment.

Jon Skeet
A: 

I prefer cobertura over EMMA. At least when I used EMMA it generated a number of false negatives (lines that were actually executed but it said they were not). EMMA may have fixed this.

TofuBeer