Setting parameters on child steps

Hi, looking for some help developing this test step. Up until now, I’ve been creating very specific steps to solve my immediate problems, but with this, I want to start moving to more robust, generic solutions so I can start building some internal packages.

As a side note, I’d like to become a bit more self-sufficient on this stuff, and I’m struggling to find documentation that helps me with anything non-trivial. So if there are docs I’ve missed that would help with this, please do point me to them!

The objectives are as follows:

  • Set constraints (limits or expected value) for a test step based on a specific resource (DUT or instrument).
  • Works with any parameter type
  • Works with any number of parameters

I’m currently thinking a step that sets the value of child steps using parameters would be a neat solution to this, having a list of parameters and being able to select a ‘source’ for the value from a list of available values of the correct type.

I’ve created a ConstraintsAttribute class to mark properties that should be available sources.

Let’s say I have the following:

public class ChildStep : TestStep
{
   public int UpperTestLimit { get; set; }
   //...
}
public abstract class DutBase : Dut
{
   [Constraint]
   public abstract int IntLimit1 { get; }

   [Constraint]
   public abstract int IntLimit2 { get; }

   [Constraint]
   public abstract string ExpectedStringValue { get; }
}

I’d want to be able to parameterise the UppertestLimit and be able to select IntLimit1 or IntLimit2 for the value.

So far, I’ve got to the point of being able to get a single value from the resource, but haven’t been able to figure out how to use it to set the value of a parameter.

    public DutBase Dut { get; set; }

    [AvailableValues(nameof(AvailableGaugeConstraints))]
    [Display("Constraint", "The limit or expected value to get from the DUT type")]
    public MemberData GaugeConstraint { get; set; }

    [Browsable(false)]
    [XmlIgnore]
    public List<MemberData> AvailableGaugeConstraints { get; set; }

    [Output]
    public object Value { get; set; }

    public GetConstraints()
    {
        Dut = DutSettings.GetDefaultOf<DutBase>();
        
        AvailableGaugeConstraints =
            typeof(DutBase).GetMembers(BindingFlags.Public | BindingFlags.Instance)
            .Where(mi => mi.GetCustomAttributes<ConstraintAttribute>().Count() != 0)
            .Select(mi => MemberData.Create(mi))
            .ToList();
    }

    public override void Run()
    {
        Value = GaugeConstraint.GetValue(Dut);
        Log.Info($"Gauge constraint {GaugeConstraint.Name} has value: {Value}");
    }
}

Any help gratefully received. TIA

Hi @benstreek,

I might not fully understand what you are asking for, but maybe we can iterate a bit to get to a solution.

To set the value you can call GaugeConstraint.SetValue(Dut, Value).

However, these constraints only have setters, so that will cause a runtime error in your case.

Hi, @rolf_madsen.

The context for this is a single test plan for similar DUTs, with different limits for certain tests determined by the DUT type.

I’ve set the limits on the DUT derived classes, and I want this step to retrieve those limits and apply them to a child step that has its properties parameterised on this step.

Hopefully, that makes more sense. If not, perhaps I’m trying to do something peculiar!