A well-designed step type can make sequence development faster, can reduce debugging efforts, can allow developers to share standardized code, and can achieve consistency among multiple test stations and separate groups. However, custom step types can require a significant amount of time to plan, program, debug, deploy, and maintain.
When designing a custom step type, you are taking on the role of a framework developer, and it is important to consider the functionality of the step type you develop in terms of the end users, the test developers.
Use these guidelines when determining the requirements for the custom step type
Custom step types store data in several properties and settings that you can use to configure the behavior of instances of the step type and manage data required for the step type functionality. These include:
Built-in step type properties exist for all step types, and the user cannot make changes to these settings in instances of the step type. In addition, any changes you make to the values of these properties will propagate to any instances of the step type.
Example: All step types define a description expression which is displayed in the Steps pane next to instances of the step. This property is present for all step types, but the value is set for each step type. The value cannot be modified in instances of the step type.
Since the description is not configurable in step instances, you can define it as a step type developer to help users create self-documenting steps. The description field is specified by an expression which allows you to create dynamic descriptions that display important step properties. When the user makes changes to these property values in instances of the step type, the description will update and allow the user to quickly see the state of the step without navigating into the step setting pane.
Example: The status expression property is used to determine the step result. This property is present for all step types, and the default value is set for each step type. In some step types, such as the Numeric Limit Test, the status expression is disabled in the step type so that it cannot be edited in individual numeric limit test steps
When designing a custom step type, you can disable any properties that will not vary between instances of the step type. This will provide you with more control over how users of the step type can modify the behavior. However, preventing users from editing step settings can limit flexibility, so you should only disable settings that you are confident that a user will never need to modify.
Keep in mind that any future changes you make to step property default values, even if you disable editing them in step instances, will not propagate to instances of the step type. Refer to Updating and Maintaining Step Types for more information on mitigating this issue.
You should not use the values of these properties to define any functionality of the step type that may need to be updated by the step type developer. For example, do not use the Post expression of the step to implement step type specific functionality. If you need to update this functionality in a future version of the step type, there will be no way to ensure that all instances of the step are updated. Instead, implement the functionality in a pre- or post- step substep.
In addition to the built-in properties, you can define custom properties specific to the step type. Use these properties to store data specifically related to the step type functionality.
Example: Numeric limit test steps contain a Limits.High property, which is unique to the Numeric Limit step type. The type defines a default value of 11 for this property, and the user can modify the value for each instance they create.
If you define a property in the results container of the step type, the property will be included in result collection. You can then use the IncludeInReport or IncludeInDatabase flags to log the data to a report or database.
By default, users can change step property values for each step instance. However, if you set the shared flag for a step property in the step type, the value will be locked to the value in the step type. Unlike step default values, updates to the value will propagate to instances of the step type.
The data types you choose for step properties should be determined by the scope of the step type. For example, consider the numeric limit test and the multiple numeric limit test steps. While the multiple numeric limit test can accommodate additional limits and has more capability, it also introduces complexity in the edit-time user interface and result logging. The more basic numeric limit test has a smaller scope and has a much simpler interface. In addition to requiring less development work, steps with a smaller scope are also easier to use by test sequence developers.
When developing your own custom step types, it is important to define the scope of the step before defining custom properties, since the properties you choose have a significant impact on the complexity of the step type.
Substeps call code modules using one of the provided TestStand Adapters. Substeps cannot be modified in instances of the step, and all changes to substep settings will propagate to instances of the step type.
Use these substeps to define functionality that applies to all instances of the step. Often, substeps will require specific data related to the behavior of the step type. Define this data in custom step properties to ensure that it is available in all instances of the step.
Implement the code module for the basic operations inherent to the step type as a Pre-Step or Post-Step substep instead of as a default module. Use the default module setting only when each instance of a step can call a different code module. The default module setting exists separately on every instance of the step, and TestStand does not update existing step instances by default when you change the setting on the step type. However, changes to substeps automatically affect all existing instances of the step type.
Edit substeps provide a graphical user interface (GUI), implemented in a code module, in which the user can modify the variables or settings of that step instance at edit-time. Typically, the Edit substep is used to configure custom step properties that you define for the step type.
Example: The Open Database step type provides a dialog via an edit substep to allow users to configure the ConnectionString and DatabaseHandle step properties, which are custom properties for the database step type.
When the user creates an instance of a custom step type, they can access the edit substep user interface using a button in the step settings pane, which launches the edit substep UI in a new window. However, you can also embed the edit substep user interface directly in the tab, like many built-in step types. This approach requires additional development effort and must be developed in a .NET language, but provides a more seamless editing interface for user of the step type. Refer to Creating Custom Step Type Edit Tabs in the Sequence Editor for more information on how to implement embedded edit substep interfaces.
A custom step type can define many properties which can be confusing if displayed to the user all at one time. When using the typical approach of edit substeps which launch in a separate window, use organizational methods within a single edit substep, such as introducing tabs, to organize the data into manageable sections. Using multiple edit substeps is not recommended because each interface must be launched independently. For example, the Open SQL Statement step implements a single edit substep with multiple tabs.
If you are using the embedded step panel approach for complex step types, it is advantageous to use multiple edit panels, since the data will be easily visible on the step tabs. For example, the Multiple Numeric Limit Test step includes two tabs for editing the source of the numeric data and the limit conditions for each data source.
In most cases, it is a better idea to use parameters to pass data rather than the TestStand API to access them directly. Using parameters is less error prone: any errors in the property names or data types will be easy to find since the properties are defined in the step type settings in TestStand, not directly in the code module. Additionally, having all the properties defined in the step configuration makes the step type more maintainable. Any changes to step properties can be accounted for without any modifications to the code module.
When you are developing and testing code modules for substeps of a custom step type, be aware that TestStand loads and reserves the code module into memory when the substep is executed. This improves performance since the module remains loaded for subsequent executions, but you cannot edit the code module until TestStand unloads it. You can unload the code module in one of two ways:
It is important to consider how to store and distribute the custom steps you create. NI recommends creating all step types in a type palette file, not within a sequence file, because TestStand searches the type palette files for step type updates when you load a sequence file. TestStand also helps you manage the reuse of steps by keeping a copy of each step type used inside a sequence file. If you deploy the sequence file without the type palette file, the sequence file still contains a copy of the step type.
As a framework developer, it is common that your step types will be used by multiple test developers. This can be a challenge, since step types have many associated files. To help manage the step type files, use the following directories to store the files for your step type
If you need to change the type of a custom property, you can do this by creating another property with the new type and retaining the property with the previous type. If you change the name or data type of a property, TestStand replaces the value of the property in step instances with the default value of the property. In addition to creating a new property with the new type, you can add logic to the step type to handle cases where a step uses the old property and the new one. For example, when TestStand implemented limit values as expressions, two new Boolean properties were added to specify to use the old numeric limit property. The UseLowExpr and UseHighExpr properties determine if the step evaluates the old numeric limits or the new expression limits.
aa06259810