Skip to content

Iptv Assist

Learn More from us

Menu
  • HOW TO
  • Firestick
  • Chromecast
  • PC Apps
  • Lg Smart TV
  • IPTV Services
  • Automation Testing
  • Smart TV
  • Software Testing Tools
  • Contact Us
Menu

How to Write Basic Groovy Script in SoapUI – SoapUi Tutorial #6

Posted on September 17, 2023

Best Iptv Service Provider 2023 With 40k+ Channels And 100k+ VOD . 24/7 Suppport . Paypal Supported

In this tutorial, we will explore the fundamentals of writing Groovy scripts in SoapUI, specifically focusing on basic scripting operations and the various operators that can be utilized in Groovy scripts in SoapUI.

Best Iptv Service Provider 2023 With 40k+ Channels And 150k+ VOD . Hurry Up

To commence our exploration of groovy scripting in SoapUI Pro, let us dive into the sixth tutorial in our comprehensive SoapUI online training series.

Recommended IPTV Service Providers

  1. IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
  2. IPTVRESALE – Rating 5/5 ( 200+ Reviews )
  3. IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
  4. IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
  5. IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
  6. IPTVTOPS – Rating 5/5 ( 43 Reviews )

 

Groovy Script in SoapUI

SoapUI Groovy Script Test Step:

The Groovy Script test step is an essential feature available in SoapUI / Pro for custom automation test script creation. This feature can be utilized for conducting functional, load, and regression tests.

Groovy, being a scripting language, integrates all Java libraries internally. As a result, all Java-related keywords and functions can be directly utilized in a Groovy script. The Java libraries come pre-installed with SoapUI and are seamlessly incorporated during the SoapUI Pro installation process.

Here’s how you can add a Groovy script to a test in SoapUI:

Step #1. Start by creating a SOAP project in SoapUI Pro using a valid WSDL document. Inside the project, create a test suite with the desired name. Within the test suite, add a Groovy script test step as demonstrated below:

Working with Operators 1

Step #2. Provide a name for the step in the dialogue box that appears, and click OK to proceed.

Working with Operators 2

Step #3. An editor will be displayed, allowing you to write your script. Alternatively, you can double-click on the Groovy step name within your test case (identified by the star prefix).

(Click on the image to enlarge)

Working with operators 66

For instance, let’s write a simple script that displays a message in the log. Here’s the one-line script:

        log.info ”soapUI script”

Step #4. To execute the aforementioned script in SoapUI Pro, click the Run icon and observe the results in the Log Output section.

Working with operators 44

Additional Points:

  • Test Script Execution: When the “Run” button within the Groovy editor is clicked, only the code within the Groovy step will be executed. Conversely, when the “Run” button for the entire test case is clicked, all the steps are executed in a sequential manner.
  • With Groovy scripting, you can easily add necessary validations to the test scripts.
  • Any number of Groovy test steps can be added to a test case.
  • Groovy scripts do not require separate compilation and interpretation to execute code similar to other programming languages like C, C++, Java, etc.
  • Within a test suite, steps can be enabled or disabled using the comment feature. To do so, utilize the following syntax:

                 // – Indicates a single-line comment.

                /* <some script> */ – Denotes a multi-line comment.

Arithmetic Operations:

Within the Groovy step editor, you can perform the following:

/* Adding Two Numbers */
int a;
int b;
int c;

// Assigning Integer Values to Variables A and B
a = 100;
b = 200;

// Adding Values of A and B, and Assigning the Result to Variable C
c = a + b

// Displaying the Resultant Value in the Log
log.info(“Result: ” + c);

In the above script, A, B, and C are variables used for storing or transferring values.

(Click on the image to enlarge)

Working with operators 55

Note: Variables in Groovy scripts are case-sensitive. Exercise caution when using them.

The following are the operators supported in Groovy:

Arithmetic Operators:

+    Addition operator / String concatenation
–    Subtraction operator
*    Multiplication operator
/    Division operator
%    Remainder operator

// Examples of Arithmetic Operators:

// Addition Operator:
int x1 = 100 + 200
log.info(“Addition Result: ” + x1);

// Concatenation of Two Strings using PLUS ( + ) operator
String city =”Timothy E.” + ” Shepherd”;
log.info(“String Concatenation: ” + city);

// Subtraction Operator:
int x2 = 200 – 100
log.info(“Subtraction: ” + x2);

// Multiplication Operator:
int x3 = 10 * 200
log.info(“Multiplication: ” + x3);

// Division Operator:
int x4 = 200 / 10
log.info(“Division: ” + x4);

// Modulus Operator:
int x5 = 10 % 3
log.info(“Reminder or Modulus: ” + x5);

The following screenshot depicts the above scripts and their respective results:

Working with Operators 6

Unary Operators:

Unary operators solely work with a single operand. For instance, ++ is known as the Increment operator, which increments the current value by 1.

Here’s an example:

int A = 100;
A++;                     // Equivalent to A = A + 1
log.info(A);

The above script will output 101. This increment operation is referred to as post-increment. Similarly, this operator can be utilized as a pre-increment operation as shown below:

int A = 100;
log.info(++A);

There is also the decrement operator (–), which decreases the current value by 1. We can incorporate this operator into the examples discussed above.

int A = 100;
A–;                       // Equivalent to A = A – 1
log.info(A);

The above script will output:
Mon Jul 21 18:02:16 IST 2014:INFO:99

The pre and post operations can also be used with the decrement operator.

Assignment Operators:

The basic assignment operator is the equal sign (=). However, there are other useful assignment operators available, such as +=, -=, *=, /=, and %=.

Let’s take a look at some samples.

int A = 100;
A += 10;                // Equivalent to A = A + 10
log.info(A);

The above script will output 110. If we use the minus-equal-to operator in the script below, the value will be 40.

int B = 50;
B -= 10;
log.info(B);

We can utilize the remaining operators in a similar manner.

int C = 10;
C *= 10;
log.info(C);

And,

int D = 50;
D /= 10;
log.info(D);

Furthermore, the remainder operator can be used as follows:

int E = 10;
E %= 3;
log.info(E);

This will divide the value 10 by 3 and assign the remainder to the variable “E”.

Conclusion:

This is just the beginning, as Groovy supports many other operators, such as logical, comparison, and conditional operators, among others. We will explore these operators in the upcoming tutorials. In our next SoapUI tutorial, we will also delve into working with properties in SoapUI Groovy scripts.

Join us in this exciting journey and don’t hesitate to leave your comments and questions below.

Related

Best Iptv Service Provider 2023 With 40k+ Channels And 150k+ VOD . Hurry Up

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • 20+ Best IPTV Service Providers In 2023 [For Your Android TV, FireStick Or PC]
  • IPTV List: Best iptv lista 2023
  • IPTV Premium: Best Premium IPTV Service Provider List And Benefits
  • Nikon IPTV Review: Over 10,000 Live Channels for $12/Month
  • Iptvwings. Com Review: +18000 Live IPTV Channels ,+70000 Movies, +40000 TV show For $15/1 month

Recent Comments

  1. How to Install and Watch NFL Game Pass on Roku? - Iptv Assist on How to Install and Watch NFL Game Pass on PS5 in 2023?
  2. How to Find Maximum Valid Defects in Any Application? - Iptv Assist on Why Does Software Have Bugs?
  3. How to Get and Watch NFL Game Pass on Samsung smart TV? - Iptv Assist on How to Install and Watch NFL Game Pass on PS5 in 2023?
  4. Chromecast Steam | How to cast Steam Games to TV? [Updated 2023] - Iptv Assist on How to Install & Watch ESPN+ on LG Smart TV? [Updated November 2023]
  5. How to Root Chromecast? [Simple Steps] - Iptv Assist on How to Copy Text from Image on iOS 15?

Archives

  • September 2023

Categories

  • Activate
  • Agile Testing
  • Alternatives
  • Android
  • APK
  • Apple TV
  • Automation Testing
  • Basics of Software Testing
  • Best Apps
  • Breakfast Hours
  • Bug Defect tracking
  • Career in Software Testing
  • Chromebook
  • Chromecast
  • Cross Platform
  • Database Testing
  • Delete Account
  • Discord
  • Error Code
  • Firestick
  • Gaming
  • General
  • Google TV
  • Hisense Smart TV
  • HOW TO
  • Interview Questions
  • iPhone
  • IPTV
  • IPTV Apps
  • Iptv Service SP
  • IPTV Services
  • JVC Smart TV
  • Kodi
  • Lg Smart TV
  • Manual Testing
  • MI TV
  • Mobile Testing
  • Mod APK
  • newestiptv.com
  • News
  • Nintendo Switch
  • Panasonic Smart TV
  • PC Apps
  • Performance Testing
  • Philips Smart TV
  • PS4
  • PS5
  • Python
  • QA Certifications
  • QA Leadership
  • QA Team Skills
  • Quality Assurance
  • Reddit
  • Reviews
  • Roku
  • Samsung Smart TV
  • Screenshot
  • Selenium Tutorials
  • Sharp Smart TV
  • Skyworth Smart TV
  • Smart TV
  • Soft Skills For Testers
  • Software Testing Templates
  • Software Testing Tools
  • Software Testing Training
  • Sony Smart TV
  • Sports
  • Streaming Apps
  • Streaming Devices
  • Tech News
  • Test Management Tools
  • Test Strategy
  • Testing Best Practices
  • Testing Concepts
  • Testing Methodologies
  • Testing News
  • Testing Skill Improvement
  • Testing Tips and Resources
  • Toshiba Smart TV
  • Tutorials
  • Twitch
  • Types of Testing
  • Uncategorized
  • Vizio Smart TV
  • VPN
  • Web Testing
  • What is
  • Xbox
©2023 Iptv Assist | Design: Newspaperly WordPress Theme