Bulent Erdemir
Bulent Erdemir

Reputation:

How to find out how much java code is really executed for a given use case in a program?

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

Upvotes: 4

Views: 271

Answers (2)

TofuBeer
TofuBeer

Reputation: 61526

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.

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1500675

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.

Upvotes: 10

Related Questions