Previous Topic: External-Subprocess StepsNext Topic: File System Snapshot


Execute External Command

Use the Execute External Command step to run an external program (such as an operating system script, an operating system command, or an executable) and capture its contents for filtering or making assertions.

The external program syntax depends on your operating system.

Enter the following parameters in the Execute External Command editor:

Execute from directory

The directory that is considered current when the external command is run. DevTest creates the directory (subject to file system permissions) if it does not exist on the system that is running the test. If the directory does not exist and cannot be created, the step fails.

Time Out (Seconds)

How long to wait before transferring to the step defined by On Time Out Execute.

If timeout

The step to run if the external command does not complete execution before the timeout value.

If Environment Error

Specifies the action to take or the step to go to if the test fails because of an environment error.

Default: Abort the test.

Output Encoding

Accept the default encoding of UTF-8 or select an alternate encoding from the drop-down list. You can also select Auto-detect to have an encoding type be selected for you.

Allow Properties

This check box determines whether properties are allowed for the next four parameters. This option changes the look of the command editor interface.

With the Allow Properties check box cleared, five check boxes are available. Here the only choice is to select the parameter or not.

Wait for Completion

If you select this check box, the step waits until the execution finishes to filter or assert on the results. If this check box is cleared, filters and assertions execute; however execution does not wait for the result of the command being run.

Kill at Test End

If the Wait for Completion check box is cleared, select this check box to kill the process after the test case finishes. This parameter lets a process run while a test case runs, then shuts down the process. A property contains the process ID of the started command.

Spawn Process

Creates a process in the operating system in which to run the command. This parameter is helpful in the following cases:

Exec Shell

Lets you run the contents of the command line in a system shell. This option is required if you must use shell process features such as redirecting (pipe) output streams to files or other commands. Depending upon your system, this option may be required for you to run system commands such as dir or ls. This check box must be selected for a Windows operating system.

Append to Environment

When the step defines environment variables, DevTest appends them to the existing environment, instead of creating an environment that defines only these variables.

With the Allow properties check box selected, there are pull-down menus that have the same functionality as shown previously, but each parameter can now be a property.

Execute External Command step

Command Line

The external command is typically only one command that is written as a shell script or batch file. You can run multiple commands when the Exec Shell option is also selected. The command string must be valid for the operating system that you are running.

Environment Variables

Allows existing environment variables to be overridden with new environment variables. If nothing is entered, the existing environment variables are used for the command. If you define an environment variable, the new variable sets are used instead of the environment variables that were used to start DevTest.

Exit Codes

Lets you base the outcome of the test on the exit code of the completed process. Enter a comma-delimited string of exit codes with a corresponding step to run when the process exits with this code.

To test your command, click Execute.

The content is now available for you to filter and add assertions.

The Execute External Command step has a default name using this convention: Command commandfirstword. If another step uses the default step name, DevTest appends a number to this step name to keep it unique. You can change step names at any time.