I have a pretty big Java project with very low code coverage, and want to increase the number of test cases. Is there any way to measure which classes are used the most in runtime? This way we can measure which classes we need to cover first. The project is a web app running over tomcat & websphere if it is important.
Share
The idea behind code coverage is not to cover as much code as possible but to cover the code that is most expensive for you.
So a good start is to look at your bug database: Is there a place in the code that shows up often? Or do you know a piece of code where you’re first thought is “I don’t want to touch that … ever“
Ask your colleagues about weak spots. Every project has them and everyone knows about them; it’s just that nobody dares to venture there.
These are excellent places to start with test cases because those are the places where the missing coverage hurts.
Rationale: There is no point to test code that works. Code that is executed often usually works because bugs were found quickly and there was a lot of pressure to fix them.