aspose file tools*
The moose likes Testing and the fly likes How to handle code coverage for catch blocks? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to handle code coverage for catch blocks?" Watch "How to handle code coverage for catch blocks?" New topic
Author

How to handle code coverage for catch blocks?

Giriraj Bhojak
Ranch Hand

Joined: Apr 03, 2008
Posts: 71
I am trying to improve code coverage of our enterprise application.
Is there an approved way to handle catch blocks?
How do i increase code coverage by running tests that lets the control go to catch block?

I hope my query is clear enough.

Thanks,
Giriraj.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Giriraj,
What tool are you using for code coverage? Different tools handle catch blocks differently.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Giriraj Bhojak
Ranch Hand

Joined: Apr 03, 2008
Posts: 71
I am using Clover.
Testing each and every catch block is exhaustive and seems improbable to me.
But there has to be way to handle most of the error conditions.

Thanks,
Giriraj.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

One way is to have less catch blocks. Can a filter or superclass handle the common ones?
Giriraj Bhojak
Ranch Hand

Joined: Apr 03, 2008
Posts: 71
That would require refactoring which unfortunately isn't an option for me right now.
I simply have to improve the coverage for existing code base.
What else could you suggest?

Thanks a ton for replying...

Giriraj.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to handle code coverage for catch blocks?