Home | Crucible | Forums

Home » Cenqua User Forums

Thread: Exception handling

Welcome, Guest

Replies: 1 - Pages: 1 - : Apr 23, 2021 5:47 AM by: brendan
Exception handling
Posted: Apr 18, 2021 9:13 AM

I am using clover mostly in the context of J2EE and find myself writing a lot of catch blocks for NamingException, CreateException and/or RemoteException. All of these exception are checked exceptions so I need a catch block but in practice the exceptions are never thrown if the application is deployed and coded correctly and the network is stable.

The result is that when I run my unit tests, it is very hard for or simple impossible to get to 100% code coverage because the catch blocks for the aforementioned catch blocks never execute.

I know that I can use ////CLOVER:OFF and ////CLOVER:ON but I would prefer not to have to put that in my code. A similar mechanism that exists for expression patterns seems much more interesting.

Is there any change that this can be built into clover?

Re: Exception handling
Posted: Apr 23, 2021 5:47 AM   in response to:


Thanks for this suggestion. You can currently exclude all catch blocks from coverage reports by using the built-in "catch" context filter. I agree that this might be too coarse-grained, and in Clover 2 you'll be pleased to know that we have plans to add support for defining regex-based filters for catch blocks.