Open TAP 9.18.5 removes the result listener when there's any unhandled exception in result listener

Hi,

Currently, we are upgrading our OpenTap from 9.10.0 to 9.18.5. After our upgrade, we found a difference in behavior.

In 9.18.5, when an unhandled exception is thrown from the custom result listeners override methods, test execution removes the result listener, but in 9.10.0, it’s different. The result listener will not be removed and will continue to listen till the test execution ends.

I just wanted to know, is there any way I can prevent the result listener from being removed when there’s an unhandled exception?

Thanks in advance for your help

Regards,
Gubendiren. R

The right way would be to fix the first result listener so that it does not throw exceptions. If that is not possible, you can create a new class that inherits from the first one but wraps the method calls in try/catch.

class ResultListener2 : ResultListener1{
     public override void OnTestStepRunStart(TestStepRun stepRun)
     {
         try
         {
              base.OnTestStepRunStart(stepRun);
          }
          catch
          {
           // handle exception?
          }
     }
}```

Then you can use this second class instead of the first one.

Thanks for the prompt support.

This would solve the problem of the result listener being removed, but this creates another problem.

We use this result listener to store the test results for regulatory purposes so, it’s not useful to continue the test execution without being able to store the results.

Is there any way I can stop the test execution and set the verdict to error when there’s any exception in the result listener?

Yes, in this case you can call TestPlanRun.MainThread.Abort().

I am not sure the verdict will be Error though, it might be set to Aborted.

Sorry correct me if I’m wrong. I think The result listener dont have access to TestPlanRun.MainThread to call abort.

They should have. Depends a bit on the OpenTAP version maybe.

MainThread is a public property of TestPlanRun.