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
- Addition Operator / String Concatenation (+)
- Subtraction Operator (-)
- Multiplication Operator (*)
- Division Operator (/)
- 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
To execute the above groovy script in a SoapUI tool, click the Run button that displays the following output.
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
To execute the above groovy script in a SoapUI tool, click the green color Run button that displays the following output, as shown below.
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.
For executing the above Groovy script, click on the green color Run button that displays the following output.
Similarly, we can use other operators supported by the Groovy script such as logical, relational, comparison, conditional, etc.