Example Code

Programmatically Changing a TestStand Step Name

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Teststand

Code and Documents

Attachment

Download All

Overview

You can use a TestStand expression to dynamically change the name of a test step in the execution window and the test report or database. This provides a convenient way to include step-related data in the test report or database.
 

Description

In many cases, it is useful to include information about the test state in the report for a test step.  You can accomplish this by dynamically modifying the name of a step using the pre-expression in the step.  In addition to including the current state in the execution window, the updated step name will also be shown in the test report or results database.

Note: You can also log additional data using other approaches, such as the Additional Results feature.  These approaches will include the data in the test report or database, but will not add information to the execution window.

 

 

This example uses the following expression to dynamically add information to the step name of a test step, including the current loop iteration and channel number:

Step.name = RunState.SequenceFile.Data.Seq["MainSequence"].Main[Step.UniqueStepId].name + " [channel: " + Locals.currentChannel + " | iteration:" + Str(Locals.i) + "]"

The expression uses Step.Name to access the step name for the current execution, and Uses the step object in Runstate.SequenceFile to access the step object in the non-executing sequence file.  This object is used because it will always have the original step name without the dynamic modifications from previous iterations of the step.

 

Hardware and Software Requirement

 

Change Step Name - TS3_1.seq

TestStand 3.1 or Compatible

 

Change Step Name - TS2010.seq

TestStand 2010 SP1 or Compatible

 

Change Step Name - TS2016.seq

TestStand 2016 or Compatible

Steps to Implement or Execute Code

  1. Open the attached Sequence file, and observe that it has a single Numeric Limit Test step.
  2. Select the test step, and click the Expressions tab.  Observe that the pre-expression is configured to append the current iteration and the current channel name.
  3. To see the step name update in the execution view, enable tracing and select a slower speed in the Execution tab of the Station Options (Configure » Station Options).
  4. Execute the sequence using Single Pass.  Observe the step name updating as it executes.
  5. View the test report.  Observe that the step name for the test results contains the dynamically added information.

 

Additional Information or References

TestStand Example: Adding Custom Data to a Report

Al B.
Staff Software Engineer - TestStand
CTA/CLD

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors