beautypg.com

Import ironpython libraries, Import .net libraries, Using mts testsuite variables in the editor – MTS Multipurpose Elite User Manual

Page 285: Mts testsuite variable api, Number variables

background image

Import IronPython Libraries

To import an IronPython library for use in a custom function, you must explicitly include the path to your
IronPython installation. To do this (assuming your IronPython installation is located at C:\Program Files
(x86)\IronPython 2.7

, perform the following:

#Import the “random” python library
import sys
sys.path.append(r"C:\Program Files (x86)\IronPython 2.7\Lib")
import random

Import .NET Libraries

To import a .NET library for use in your custom function:

#Import only the “Random” .NET Class
import clr
clr.AddReference("System")
from System import Random

#Import the entire “System” .NET library
import clr
clr.AddReference("System")
from System import *

Using MTS TestSuite Variables in the Editor

The best practice for using MTS TestSuite variables within the custom function editor is to pass the variables
themselves to custom functions as parameters. That way, you can interact with the variables in the same
way you would normally use Python variables. This is the least error-prone approach.

However, sometimes MTS TestSuite variables must be modified within a custom function. In this situation,
refer to the API information in the following section. For clarity, all MTS TestSuite variables will appear as
bold light blue text. To avoid confusion, avoid declaring a local variable within your custom function with
the same name as an MTS TestSuite variable.

MTS TestSuite Variable API

The MTS TestSuite Variable API may be subject to change during future releases.

Number Variables

Description of Number Variables

Description

Example (using variable num)

Method

Get the numeric value of NUM

NUM.Value.ValueAsDouble

Value

Set the numeric value of NUM

NUM.SetValue(value)

SetValue

MTS TestSuite | 285

Working with Variables