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

Is it possible to connect an agent or something to jvm before starting the application (or application server) and have a report showing which part of the code base in the class path is actually executed for this use case? I want to find out how much code remains unexplored for my simple servlet application running on an application server that does not use many j2ee technologies such as JCA, JMS, CMP, etc.

Regards, Bulent Erdemir

+4
source share
2 answers

What you are looking for is a code coverage tool .

For Java, I had great success with EMMA . You should be aware that any code coverage tool can significantly affect performance - it is usually used for unit testing to verify that your device tests fall into the appropriate parts of your code. You could use it for a trial run of a web application, but I would recommend not using it for production deployments.

+10
source

I prefer cobertura through EMMA. At least when I used EMMA, it created some false negatives (lines that were actually executed, but they said they were not). EMMA may have fixed this.

0
source

All Articles