3

I am using Delphi 11 with the DUnitx unit testing. I know that I can turn off "Language Exceptions" in Tools/Options. But this turns it off for all projects.

Is there a way to turn them off for "unit testing", or "per project".

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41

3 Answers3

4

The only way I know of to accomplish this, in all Delphi versions, is by using breakpoints.

Put a breakpoint at the point in the code where you want to disable the debugger's exception handling. Right-click on the breakpoint to go into its properties. In the "Advanced" options, turn off the Break option and turn on the Ignore subsequent exceptions option.

Place another breakpoint at the point in the code where you want to re-enable the debugger's exception handling. In the properties, turn off the Break option and turn on the Handle subsequent exceptions option.

Now run the code, and you can debug as needed, except for the code you masked off.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
2

GExperts has got an expert that can filter specific exceptions, not just by exception type but also depending on the message. And it's project specific. I'm not sure how well this works with Delphi 11 though.

It also has a side effect: The IDE gets the focus for each of the exceptions and will then switch back to the program. This makes the computer nearly unusable if there are many exceptions.

dummzeuch
  • 10,975
  • 4
  • 51
  • 158
  • I tried ignoring the exception in GExperts, but then Delphi picks it up instead of GExperts. That's in Delphi 11, Is that not what it does in Delphi 10 ? – Rohit Gupta Jun 17 '22 at 04:36
  • 1
    As I said, I haven't really tested it with Delphi 11 because it is a pain in the lower back to use that. In earlier Delphi versions, if you filter an exception, the Delphi exception dialog will not be shown. Since that expert hacks into the Delphi IDE packages, it doesn't surprise me that it doesn't work with Delphi 11. – dummzeuch Jun 18 '22 at 09:14
  • I have now tested this functionality with Delphi 11 and it works fine for me. – dummzeuch Aug 01 '22 at 11:35
1

If you use DUnitx for testing, then I would recommend using TestInsight. This is a very good way to implement the unit testing into the Delphi IDE.

The Testinsight plugin compiles the test program and runs it without the debugger.

Download TestInsight

Watch Video

Or simply run your test program without the debugger: Ctrl+Shift+F9

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
Benedikt
  • 767
  • 6
  • 13
  • I had looked at TestInsight but couldn't figure out the advantage. I have installed it, one advantage is that in this case it's a console application and DUnit doesn't allow one to pick and chose the tests. But it looks like TestInsight does. On the flip side, I really want to automate the compile and testing with Jenkins, so it doesn't improve anything. – Rohit Gupta Jun 17 '22 at 11:58
  • I have never run an application without debugging from the IDE before. The only reason it, from the IDE is because I am debugging it. But that is a good solution to avoid the exception breaks.. – Rohit Gupta Jun 17 '22 at 11:59