Exploring Coverage Analysis Views > Setting Preferences for Coverage Views > Filtering Out Catch Block Data
The data for catch blocks is included in the following metrics:
Catch blocks, however, are often impossible to test. If you choose not to test them, you may find it easier to interpret your results without the catch block data inflating the missed values. You can set a filter to remove the data from the calculations.
To filter out catch block data from calculations:
1 Select Window > Preferences.
3 Select Filter out Catch Blocks.
When you return to a Coverage view, the calculations reflect the filter setting.
Although it is not generally considered good coding practice, it is possible that a line can have both normal statements and catch block statements.
Catch block filters do not apply in the followings situations:
• Try and catch appear in the same line of code
try { Thread.sleep(1000); } catch (Exception e) {}
If Thread.sleep(1000) is executed, coverage is 100%; if not, coverage is 0%.
• Executed code and catch appear in the same line of code
System.out.print(obj.toString());
System.out.println(); } catch (Exception e) {
If System.out.print() is executed, the coverage is 100% regardless of whether or not it throws an exception.