I understand your problem, but personally, I donβt think it is useful to be able to change the default behavior of F9 .
You have some test cases that are expected to throw exceptions. (NOTE: I actually think of tests that check for specific exceptions when bad inputs are given. No exception is "handled" by the application.) And I agree that in most cases you should not warn about this. However, an exception in other test cases would be a problem that I would like to get about as quickly as possible.
Therefore, my preferred mode of operation is usually notified of exceptions. And to have explicit code in some testing cases that explicitly disables exception notification only in the context of tests that will throw production code exceptions.
I have a technique that works very well for this.
In a test that was expecting to get exceptions, I write the following code:
begin TIDEDebugTools.DisableBreakOnExceptions; try //Test code ... finally TIDEDebugTools.EnableBreakOnExceptions; end; end;
I think you need the source code for these two methods? :)
unit IDEDebugTools; interface type TIDEDebugTools = class(TObject) public class procedure DisableBreakOnExceptions; class procedure EnableBreakOnExceptions; end; implementation { TIDEDebugTools } class procedure TIDEDebugTools.DisableBreakOnExceptions; begin end; class procedure TIDEDebugTools.EnableBreakOnExceptions; begin end; end.
Where are the rest you ask?
There is no one - this!
... but there are a few instructions you need to follow:
- Add a breakpoint for each of the methods.
- Edit the breakpoint properties.
- Select advanced options.
- Turn off Break
- And enable the options "Ignore subsequent exceptions" and "Process subsequent exceptions" for the corresponding corresponding method.
This is close to the jpfollenius idea for compiler directive parameters. It also addresses David 's issue of how you include these exceptions again. All you have to do is disable breakpoints to get all exceptions again.
Additional thoughts:
You mentioned:
Some test codes throw exceptions that are handled by the application.
If your application handles all of these exceptions, then:
- Are your tests localized enough? If you test such large chunks of functionality, tests are more like system tests - and they are very difficult to maintain.
- Do you use too many exceptions to handle business processes?
- Is your application for a large number of non-local exclusions on swallowing?
Basically, it seems to me that your wording suggests "a bunch of exceptions that you donβt care too much about because they are" handled "." Many people make mistakes thinking that they handle exceptions when they simply swallow them and hide root problems.