Hi everyone,
I’m building a test plan programmatically in C#, and I’m running into a data‑flow issue involving a RepeatStep / RepeatUntil step and output propagation.
My test plan structure looks like this:
Test Plan
- RepeatUntil (stop when data is generated by StepA )
- StepA_Producer // generates a string OutputValue
- StepB_Consumer // needs OutputValue
- StepC_Consumer // needs OutputValue
StepA_Producer pools some data, and sets the verdict to Pass when data is available
I can see that OutputValue is found, but the steps after the repeat (StepB_Consumer and StepC_Consumer) always receive null for the mapped value.
I used programmatic I/O assignment, which works perfectly if the steps are not inside a Repeat, but inside a RepeatUntil, the value never propagates to the parent test plan.
InputOutputRelation.Assign(
inputObject: stepB,
inputMember: destMember,
outputObject: stepA,
outputMember: srcMember
);
What is the recommended / best‑practice solution in OpenTAP to transfer data that is produced inside a repeat\childStep to nextSteps\parentSteps ?
Thanks!
Hi @t_marius,
There are some scoping rules that apply here. Basically the scope has to be same level or higher and the step has to come before. So sibling steps of the current step or parents that comes before.
Here is an example of what "My Step"s properties can get the output from.
1 Like
@rolf_madsen Thank you for the info . I just made a test using Input, and the data can be linked to the next steps. We will have to use some global variable in the future, but for now I’m prospecting what kind of data sharing mechanism OpenTAP provides already. Cheers!
I would not recommend a global variable. Test steps can refer to each other directly.
So for example, you could make an interface for providing values (or just use the step type directly):
public interface IMyValueProvider : ITestStep
{
int TheValue { get; }
}
public class StepA : TestStep, IMyValueProvider
{
public int TheValue { get; private set; }
public override void Run()
{
TheValue = 5;
}
}
public class StepB : TestStep
{
// Allows you to reference the other step.
public IMyValueProvider OtherStep { get; set; }
public override void Run()
{
Log.Debug("The value was: {0}", OtherStep.TheValue);
}
}
This allows you to select the step like this:
1 Like
This is interesting, we are trying to avoid coupling as much as possible, so I think for the interface example will definitely have some use cases in our app. Thanks