End Event in OpenTap

Hi, is there any way to have a end event or abort event declared in opentap, that whether test fails or pass it should always do that. For example- we have a testplan and we want an event to run , like power off radio or collect log, every time it ends/failes/abort/pass. Is there any type /function class declared in open tap to be able to do so.
Please advise.

Thanks

Hi,

You can either use a result listener plugin or implement ITestPlanRunMonitor interface according to your needs.

Another thing you can consider using is DUT and Instrument plugins’ Open() and Close() methods.

Hi,

Thanks for your reply ! I want to use it for my app developed in c#. Is there any example dll i can refer to know how to implement ITestPlanRunMonitor?

You can create a class like this:

[Browsable(false)]
public class RunMonitor : ComponentSettings<RunMonitor>, ITestPlanRunMonitor
{
    // After test plan run is started
    public void EnterTestPlanRun(TestPlanRun plan)
    {
    }
    
    // After test plan run is finished
    public void ExitTestPlanRun(TestPlanRun plan)
    {
    }

}

To implement ITestPlanRunMonitor you must also inherit from the ComponenetSettings class. When you create a class like this, OpenTAP will automatically create an instance of it and methods inside the class will be called when you run a test plan.

Hi,

Thanks for your advise. I tried this but can you advise why Iam not able to use Log.Info/Log.Error/Log.Warning inside ExitTestPlanRun function?

Log.Error/Log.Warning are extensions methods for TraceSource. To use them, do like this:

    ///...
   static readonly TraceSource log = Log.CreateSource("run-monitor");   

    public void EnterTestPlanRun(TestPlanRun run){
     log.Info("EnterTestPlanRun invoked");
    }
   ///...
2 Likes