Is there a way to get the ordering/sequence of the test steps in the test plan during execution? For example of one use case: in a test plan with multiple Test Step A, can we check during the runtime of Test Step A, if it is the last/final Test Step A in the test plan. (meaning there are no succeeding Test Step A in the test plan). Is this something that is available in the OpenTAP framework?
@antonio.quizon Welcome to the Forum!
There is not a simple way to do this. In part because due to Looping and other Flow Control steps it is not always clear when a test will end.
Can you share a bit more about what you are looking to do and we can maybe suggest a better solution. My initial thinking is that something like this would be better in a PostPlanRun method, which is guaranteed to be called at the end of a test.
Thanks for the response! Basically, for my use case, I have a test plan with multiple test steps that are of type “Tcoil”. For each of these test steps, I need to check whether if is the last “Tcoil” test step in the test plan. If it is the last “Tcoil” step, we will program certain settings to the DUT.
Currently, whether to run this in Run method or PostPlanRun is not decided, but I believe it should be in the Run method before the other test steps’ Run method as we will change some DUT settings.
One option could be to leverage the PrePlanRun to detect this, and handle the DUT programming in the Run.
Every test step has a Parent object. If you get the top level parent (Test Plan), you can then access the ChildTesSteps object. You could walk this object to find all of the Tcoil steps. Each step will have an unique Id, that you can map.
Parent.ChildSteps
var stepId = this.Id
From there, you could set a private variable within the Test Step:
bool lastTcoilStep = true;
And then check for this in your Run method, and do any DUT configuration if set to true.
maybe like this?
TestPlan testPlan = this.GetParent<TestPlan>();
var allSteps = testPlan.ChildTestSteps.RecursivelyGetAllTestSteps(TestStepSearch.EnabledOnly);
Tcoil lastTcoil = allSteps.Where(step => step is Tcoil).Last() as Tcoil;
bool imTheLastTcoil = this == lastTcoil;