nav-img
Advanced

Adding a Data Instruction

Data instructions define and operate data. Four arithmetic operations (addition, subtraction, multiplication, and division) are supported. You can set data precision.

Procedure

  1. Log in to the CPTS console and choose CPTS Test Projects in the navigation pane on the left.
  2. Locate the target CPTS test project and click Edit Test Task.
  3. On the Test Tasks tab, select the case to which you want to add a data instruction, and click Add Data Instruction.
  4. Click Add Parameter, and configure Parameter Name, Parameter Logic, and Value Assigned.

    • Parameter Name

      Name of the parameter to which the parameter logic result will be assigned as the parameter value.

    • Parameter Logic
      1. To assign a constant value to a parameter, enter a character string, for example, 1.23 or abc.
      2. To assign a variable value to a parameter, enter $ in the text box. In the displayed Insert Variable dialog box, select a variable type.

        If you set Type to Custom, set the following parameters:

        1. Scope: Select a variable scope.
        2. Name: Enter the name of the custom variable.

        If you set Type to System, select a function. For details, see Table 1.

        Table 1 Functions

        Name

        Description

        ID number

        Randomly generates an ID number.

        Phone number

        Randomly generates a phone number.

        Random integer in a range

        Randomly generates an integer within your specified range.

        Random character string

        Randomly generates a string consisting of lowercase letters and numbers based on your specified string length (1 to 32 characters).

        Timestamp

        Generates a timestamp for the current time based on your specified unit. A 10-digit timestamp represents time in seconds whereas a 13-digit timestamp represents time in milliseconds.

        UUID

        Randomly generates a string of 32 hexadecimal characters without hyphens (-).

        If you set Type to Arithmetic operation, select an operation.

        1. Select +, -, x, /, or Rounding from the drop-down list box, and click Select.
        2. Click . In the displayed dialog box Edit Arithmetic Operation, set the following parameters:
          • Expression: Enter operands for the arithmetic operation. An operand can be a number (such as 1.23), a global or local variable, or the result of the previous data instruction. You can reselect the operation here.
          • Rounding: Select how the expression result will be rounded. For details, see Table 2.
            Table 2 Rounding options

            Name

            Description (Using Two Decimal Place Rounding as an Example)

            Away from zero

            Rounds the number in a way that the result heads away from zero. For example, 1.234 is rounded to 1.24, and –1.234 is rounded to –1.24.

            Towards zero

            Rounds the number in a way that the result heads towards zero. For example, 1.234 is rounded to 1.23, and –1.234 is rounded to –1.23.

            Ceiling

            Rounds the number towards positive infinity. Positive numbers will be rounded up, whereas the unwanted digits of negative numbers will be simply discarded. For example, 1.234 is rounded to 1.24, and –1.234 is rounded to –1.23.

            Floor

            Rounds the number towards negative infinity. The unwanted digits of positive numbers will be simply discarded whereas negative numbers will be rounded down. For example, 1.234 is rounded to 1.23, and –1.234 is rounded to –1.24.

            Half up

            If the first digit to be discarded is smaller than 5, the digit and all the digits that follow are simply discarded. Otherwise, the last retained digit is increased by 1 in value. For example, 1.234 is rounded to 1.23 and –1.235 is rounded to –1.24.

            Half down

            If the first digit to be discarded is smaller than 6, the digit and all the digits that follow are simply discarded. Otherwise, the last retained digit is increased by 1 in value. For example, 1.235 is rounded to 1.23 and –1.236 is rounded to –1.24.

            Banker's

            Rounds the number to its nearest even integer. For example. 1.2350000 is rounded to 1.24, 1.2250000 is rounded to 1.22, and 1.2250001 is rounded to 1.23.

            None

            The number is not rounded.

          • Retained Decimal Places: The maximum number of decimal places is 32.
        3. Click OK.

        Note

        If you specify multiple logics for a parameter, all the logics are combined as a character string and the string is assigned to the parameter as its value.

    • Configure Value Assigned.
      • If you select Repeatedly from the drop-down list box, a value is assigned each time the parameter value is needed in a thread.
      • If you select Once from the drop-down list box, the parameter value is assigned only once in a thread.

  5. Click OK.