Saving Dynamic Members to Test Plan

Hi,

I have been developing a plugin for assigning run time variables using Flee (Fast Lightweight Expression Evaluator) library. My goal is creating a menu model to assign a variable to a test step property.

I achieved this using a dynamic member and adding it to the test step. I add the dynamic member, which is a variable object, as follows:

var variableObjectMember = new DynamicMember()
{
    Name = "Variable",
    TypeDescriptor = TypeData.FromType(typeof(VariableObject)),
    DeclaringType = TypeData.FromType(typeof(ITestStep)),
    Readable = true,
    Writable = true,
    Attributes = new object[2] {
        new DefaultValueAttribute((string) null),
        new BrowsableAttribute(false)
    }
};


 var variableObject = new VariableObject()
 {
     MemberName = member.Name,
     VariableName = variableName
 };

DynamicMember.AddDynamicMember(step, variableObjectMember);
variableObjectMember.SetValue(step, variableObject);

I can add the dynamic member and can see the member while debugging. My issue starts here, I can’t save the dynamic member to the test plan file. Is there a way to achieve this? Can I save and load dynamic members?

Hi @btyilmaz this isn’t an exact answer to your question, but are you aware of the new MixIns and Expressions features that were added in 9.22? It may help you accomplish what you are trying to do:

2 Likes

Hi @brennen_direnzo ,

Thanks for the answer.

I actually got the inspiration from the expressions plugin. What I am trying to do is creating a variable table that can be used in the test station. We thought we can develop a plugin that can create variables, use them inside expressions and assign their values to the test step’s properties.

I think I am close to the answer though, I need to create a serializer plugin for serializing my variable object.

I found the solution. I saw an object called something like dynamic member provider while debugging OpenTap’s methods. I created a dynamic member provider using IDynamicMemberProvider interface. No serializer needed. :slightly_smiling_face:

2 Likes