Table of contents
1.
Introduction
2.
Script Assertion 
2.1.
Availability 
2.2.
How to Create an Assertion?
2.2.1.
Functional Tests 
2.2.2.
Virtual Tests 
2.2.3.
APIs(Virtual)
3.
Response SLA Assertion
3.1.
Availability
3.2.
How to Create an Assertion?
3.2.1.
Functional Tests 
3.2.2.
Security Tests
4.
Frequently Asked Questions 
4.1.
What do functional tests check in Script Assertion?
4.2.
How to change the font in the editor?
4.3.
Is it important to assert the value before testing?
4.4.
What do you mean by connection timeout?
4.5.
How can we set the connection timeout?
5.
Conclusion
Last Updated: Mar 27, 2024

Script and Response SLA in Ready API

Author Geetika Dua
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

This blog will go through the script and response SLA in ReadyAPI. Keep reading if you are keen to know about this technology and strengthen your concepts.

intro

Script Assertion 

Availability 

The Script assertion uses a groovy script to perform checks on the message. We use it to verify the message content, headers, properties, and other components.

How to Create an Assertion?

Depending on the application, we can validate the following information.

Functional Tests The request or response
Security Tests The request only
APIs(Virtual) The response only

 

Functional Tests 

The steps are-

  • Open the test step as shown in the image.
ss
  • Click on add assertion, and the following dialog appears. Select ‘Script Assertion’ Assertion or select it manually.
ss

Assertion script mainly has the following objects-

Object Description
log Log is an Apache Logger used to post messages.
Context This is a TestCaseRunContext object that gives an interface to test steps and test runner.
messageExchange messageExchange is an object that provides access to a scripting interface for requests and response data.

 

You may enter your script in the edit box and run it.

Virtual Tests 

ss

 

ss

Assertion script mainly has the following objects-

Object Description
log Log is an Apache Logger used to post messages.
Context This is a TestCaseRunContext object that gives an interface to test steps and test runner.
messageExchange messageExchange is an object that provides access to a scripting interface for requests and response data.

 

You may enter your script in the edit box and run it.

APIs(Virtual)

ss

 

ss

Assertion script mainly has the following objects-

Object Description
log Log is an Apache Logger used to post messages.
Context This is a TestCaseRunContext object that gives an interface to test steps and test runner.
messageExchange messageExchange is an object that provides access to a scripting interface for requests and response data.

 

You may enter your script in the edit box and run it.

Response SLA Assertion

The job of Response SLA(Service Level Agreement) assertion is to ascertain whether the response comes on time or not. It is not the same as a connection timeout.

  • To begin with, ReadyAPI downloads the response.
  • After the download, it compares the response time against the SLA.

Availability

This assertion is present in various ReadyAPI applications. It validates the following-

Functional tests Response
Security tests Response

 

How to Create an Assertion?

Functional Tests 

  1. The first step is to open a test step.
  2. Click on Add assertion.
ss
ss

Navigate to the New Assertions dialog and search for the Response SLA assertion. You can also select it manually in the SLA category. To set up the assertion, add the maximum expected response time.

Security Tests

  1. The first step is to open a security test.
  2. Click on Response Assertion.
  3. Click + (plus sign).
ss

 

ss

Navigate to the New Assertions dialog and search for the Response SLA assertion. You can also select it manually in the SLA category. To set up the assertion, add the maximum expected response time.

Must Read Apache Server

Frequently Asked Questions 

What do functional tests check in Script Assertion?

Functional tests check both request and response.

How to change the font in the editor?

You can alter the font using the CTRL+mouse wheel.

Is it important to assert the value before testing?

Yes, it is important to have the value to assert before testing the script.

What do you mean by connection timeout?

The connection timeout is used to terminate test step execution if the server doesn't respond in a specific time frame.

How can we set the connection timeout?

We can set the connection timeout in a property called timeout or globally by Preferences > HTTP > Socket timeout.

Conclusion

In this blog, we studied the details of Script and Response SLA in Ready APII. You may refer to the official documentation for further information on the topic.

For more information on ReadyAPI, refer 

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enroll in our courses and refer to the mock test and problems available. Take a look at the interview experiences and interview bundle for placement preparations.

Happy Coding!

Live masterclass