Programatically Adding ChildTestStep throws exception

Hi Support Team,

We are planning to use OpenTAP 9.18.5. But we are facing issue when programmatically adding ChildTestSteps in the code. Kindly provide solution or suggestion. This was working fine in OpenTAP 9.10.4 version.
This is broken in the latest release. Great to get feedback ASAP.

Example :
///


/// Constructor
///

public SetProgrammerDevice()
{
TestType = TestStepType.NonMeasurement;

        ChildTestSteps.Add(new SetGlobalParameter()); 
    }

Where,
ChildTestSteps → TestStepList
SetGlobalParameter → This is user defined test step derived from OpenTap.TestStep

Below is the exception Details,
2022-09-26 17:08:43.694076 ; Main ; Error ; Caught exception while instantiating test step of type ‘SHS.SMI.ITSComponents.TestFunctions.TestSteps.SetProgrammerDevice’.
2022-09-26 17:08:43.695826 ; Main ; Debug ; TargetInvocationException: Exception has been thrown by the target of an invocation.
2022-09-26 17:08:43.699825 ; Main ; Debug ; at Keysight.OpenTap.Gui.TestPlanGrid.a(ITypeData A_0, Action& A_1)
2022-09-26 17:08:43.699825 ; Main ; Debug ; Inner ArgumentException: Cannot add test step of type SetGlobalParameter to SetProgrammerDevice
2022-09-26 17:08:43.699825 ; Main ; Debug ; at OpenTap.TestStepList.InsertItem(Int32 index, ITestStep item)
2022-09-26 17:08:43.699825 ; Main ; Debug ; at System.Collections.ObjectModel.Collection`1.Add(T item)
2022-09-26 17:08:43.699825 ; Main ; Debug ; at SHS.SMI.ITSComponents.TestFunctions.TestSteps.SetProgrammerDevice…ctor() in D:\TFS\TAP-Plugin\TAP-Plugin_Prime\TapPlugin\Source\ITSComponents.TestFunctions\TestSteps\SetProgrammerDevice.cs:line 110
2022-09-26 17:08:43.707136 ; Main ; Debug ; Exception caught at:
2022-09-26 17:08:43.778905 ; Main ; Debug ; at OpenTap.ITestStep AddStepToPlan(OpenTap.ITypeData, OpenTap.ITestStepParent, Boolean)
2022-09-26 17:08:43.778905 ; Main ; Debug ; at Void c(OpenTap.ITypeData, Boolean)
2022-09-26 17:08:43.778905 ; Main ; Debug ; at Void c(OpenTap.ITypeData)
2022-09-26 17:08:43.778905 ; Main ; Debug ; at Void i(System.Object, System.Windows.RoutedEventArgs)

I suspect this may be the root cause:

Do you have this attribute on the SetProgrammerDevice class?
[AllowChildrenOfType(typeof(SetGlobalParameter))]

4 Likes

Hi David,
The solution works well. Thanks for the prompt help!

3 Likes

Great to hear! No prob.

1 Like