This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to handle code coverage for catch blocks?

 
Giriraj Bhojak
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giriraj,
What tool are you using for code coverage? Different tools handle catch blocks differently.
 
Giriraj Bhojak
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way is to have less catch blocks. Can a filter or superclass handle the common ones?
 
Giriraj Bhojak
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic