How to perform additional action before aborting a TestPlan

I have a use case where in case of a Step failure, I need to perform additional action like collecting a debug log before terminating a test plan.
I see that ‘If Verdict’ allows me to either Run Children or Abort Test Plan.
Is there a clean way to implement an extra step before the TestPlan is aborted in case of a previous Step failure?

Hi @nav_dhillon,

If its a child test step you always have the chance to do things in the ‘finally’ part of a test step.

Otherwise, I’d say it sounds like something that should just be part of the regular log file?

Thanks for the quick reply, @rolf_madsen .
The logic to collect the logs in case of failure needs to be separate from other Steps’ logic as it will be reused in other TestPlans.
The reason to not include debug logs in the main log file is that it has significant size and overhead and some of the files that are collected are not text files.

I can possibly create an ‘Abort Test Step’ that I can insert after collecting debug logs but it doesn’t seem very clean and I’m also concerned about the number of times I’ll have to repeat the same logic in the TestPlan.

If you have any other suggestions on how to do this, please let me know.

What about you just create a separate log stream for you diagnostic log data and then have a result listener which saves the log stream if the test plan verdict is Error?

You could use this with the new artifacts feature in OpenTAP 9.22 to notify that this artifact has been published.

Thanks, @rolf_madsen that sounds promising. If you have any documentation link or examples of this could you please point me to it so I can have a look?

So, you can read about artifacts here: OpenTAP

Saving your data I guess you can do whatever way you want, I dont really have any good suggestions for that.

Hi @rolf_madsen : I’m still looking into this. After reviewing it, I like the Artifacts feature it’s very close to what I want but in this case the communication logic and connection handle reside withing the DUT class and the connection handle is needed to invoke log collection. If I have to do this inside Artifacts I need to get access to the TestPlan verdict and DUT object in the ResultListener and that needs to happen before DUT calls Close().
Another somewhat hacky way to do this could be to somehow read the TestPlan status in DUT Close method and collect logs
Please let me know if you have any further thoughts on how I can use one of the two approaches above, if not something else entirely.

Cant you share the TestPlanRun with the DUT during a PostPlanRun callback in some test step you know always is in the plan?