Purpose

This example demonstrates how to use the TestStand API to create and assign values to PropertyObjects. With the exception of the TestStand Engine, any object in TestStand can be accessed as a PropertyObject. This arrangement allows the methods demonstrated in this example to be used with many objects in TestStand, including step properties and variables.

Example File Location

<TestStand Public>\Examples\TestStand API\Creating New Properties Using API\DotNet\Creating New Properties Using API.seq

Highlighted Features

  • TestStand API

Major API

  • Engine.NewPropertyObject
  • PropertyObject.NewSubProperty
  • PropertyObject.InsertSubProperty
  • PropertyObject.SetValString
  • PropertyObject.SetValNumber
  • PropertyObject.SetValBoolean
  • PropertyObject.SetValVariant
  • PropertyObject.SetFlags

Prerequisites

Report generation should be enabled in order to see the result of adding a PropertyObject to the Result container of a step.

How to Use This Example

Complete the following steps to run the example:

  1. Select Execute»Single Pass to run the sequence.
  2. TestStand will display Message Popups to explain each section of the example. After each section completes, the execution will automatically break to allow you to observe the results of each approach.
  3. When you are ready to continue execution, simply click the green Resume button on the debug toolbar.
  4. After execution completes, examine the report to observe the results of the final section, where a PropertyObject named SpecialResults was added to a step’s Result container.

Complete the following steps to review the sequences and steps in this example:

  1. On the Sequences pane, select the MainSequence. The MainSequence contains four Sequence Call steps corresponding to the different approaches demonstrated in this example.
  2. On the Sequences pane, select the Create New PropertyObject sequence. This sequence uses the Engine.NewPropertyObject and PropertyObject.InsertSubProperty API calls to create a new PropertyObject and insert it into the Locals container as a new Local variable. Although this method of creating PropertyObjects is less common than other approaches, it is included for completeness.
  3. On the Sequences pane, select the SetVal Methods sequence. This sequence uses the PropertyObject.SetValString, PropertyObject.SetValNumber, and PropertyObject.SetValBoolean methods to create PropertyObjects and insert them as Local variables. This approach allows you to create and assign a value to a PropertyObject with a single API call.
  4. On the Sequences pane, select the Create New Container sequence. This sequence demonstrates a method of creating complex container structures with the SetVal methods. The PropertyObject.NewSubProperty method is used to create a container field for error data, which is a defined type in the TestStand Types pane. Additionally, this sequence uses a PropertyObject.NewSubProperty method call to create an array and assigns a value to that array using the >PropertyObject.SetValVariant method.
  5. On the Sequences pane, select the Insert PropertyObject Into Step Results sequence. This sequence creates a new PropertyObject and inserts it into the step’s Result container. The PropertyObject.SetFlags TestStand API method is used to mark this PropertyObject to be included in the report generated after execution. This demonstrates a common use case for creating new PropertyObjects in a test sequence.