Javatpoint Logo
Javatpoint Logo

SoapUI Operator Using Groovy Script

In SoapUI, we can use the Groovy Script editor to perform Arithmetic operations. The Arithmetic operator is used to perform a simple operation in SoapUI Groovy Script like addition, subtraction, multiplication, division, etc.

The following are the operation supported by the groovy scripting in a SoapUI.

Arithmetic Operators

  1. Addition Operator / String Concatenation (+)
  2. Subtraction Operator (-)
  3. Multiplication Operator (*)
  4. Division Operator (/)
  5. Modulus or Remainder Operator (%)

To create a groovy file in SoapUI, right-click on TestStep and choose Groovy Script to open the editor. Save the groovy file as Groovy Script Arithmetic and then write the following code, as shown below.

Groovy Script Arithmetic


SoapUI Operator Using Groovy Script

To execute the above groovy script in a SoapUI tool, click the Run button that displays the following output.

SoapUI Operator Using Groovy Script

Unary Operators

A unary operator is a single operator that works with only one operand to produce a new value.

Right-click on TestStep and choose Groovy Script to open the editor. Save the groovy file as Groovy Script Unary and then write the following code, as shown below.

Groovy Script Unary


SoapUI Operator Using Groovy Script

To execute the above groovy script in a SoapUI tool, click the green color Run button that displays the following output, as shown below.

SoapUI Operator Using Groovy Script

Assignment Operator

The assignment operator is used in the groovy script to assign the value either on its right or the left. Generally, the assignment operators use equal sign (=), +=, -=, *=, /=, %=.

Right-click on TestStep and choose Groovy Script to open the editor. Save the groovy file as Groovy Script Assignment and then write the following code, as shown below.


SoapUI Operator Using Groovy Script

For executing the above Groovy script, click on the green color Run button that displays the following output.

SoapUI Operator Using Groovy Script

Similarly, we can use other operators supported by the Groovy script such as logical, relational, comparison, conditional, etc.


Next TopicProperty Transfer




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA