Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Data Driven Function testing
2.1.
Import the Virtual API
2.2.
Create a Test Case
2.3.
Create a Data Source
2.3.1.
Create a data source
2.3.2.
Test the data source
2.4.
Validate With Assertion
2.4.1.
Get response
2.4.2.
Create an assertion
2.5.
Run the Test
3.
Frequently Asked Questions
3.1.
What is the Ready API used for?
3.2.
How many types of Data Driven Function testing are there?
3.3.
What are Environments in Ready API?
3.4.
What are the major types of assertions available in ready API?
3.5.
How are data driven function testing carried out?
4.
Conclusion
Last Updated: Mar 27, 2024

Data Driven Function testing in Ready API

Author Shiva
0 upvote

Introduction

For development teams concerned with developing test automation across any workflow, ReadyAPI is a low-code API testing platform. 

introductory image

The API quality required for Agile and DevOps software teams is accelerated by ReadyAPI, which enables teams to build, organize, and run automated functional, security, and performance tests through a single centralized interface. Start by importing API definitions such as OpenAPI/Swagger or AsyncAPI, testing and recording real-time API traffic, or virtualizing web services to eliminate pipeline dependencies.

Data Driven Function testing

This article explains how to use the automatic creation of parameter values to develop a straightforward data driven function test.

data driven image

Complete the actions listed below to develop a data-driven test:

  • The virtual API that you will use in this lesson is contained in a project that you may download and import.
     
  • Make a project that includes a minimum of one test case.
     
  • For that project, including a data source.
     
  • In order to verify test results, add an assertion.
     
  • Execute the test.

Import the Virtual API

You must import and start a virtual API for this section so that requests may be sent to it.

  • Download the virtual API's packed ReadyAPI project here from smartbear.
     
  • Choose the downloaded project in the window that appears by choosing File > Import Packed Project:
     

example image 1
 

  • Indicate the location where the project will be saved and unzipped.
     

example image 2
 

  • To execute the virtual API, choose it in the Navigator and click the green triangle with a tilt.
     

example image 3
 

When the API gets queries with an email in the query string, it returns results based on the value of the email. You will develop a test step that will send queries to the hypothetical API in the following tutorial step.

Create a Test Case

You must first build a project with at least one test case in order to do functional testing.

  • To create a fresh functional test, choose New Functional Test under the file section.
     

example image 4
 

  • Click on Endpoint.
     

example image 5
 

 

example image 6

 

  • Choose whether you want to add the URL you have added to an existing project or create a new one on the wizard's following page.
     

example image 7
 

  • New requests may have assertions added to them on the wizard's subsequent page. The proposed assertions will not be used in this tutorial, so deselect them and click Next.
     

example image 8
 

A project will be created by ReadyAPI, and a confirmation dialog will appear. Shut it. Your most recent test makes a single request to the given URL. You must add a data source in the tutorial's subsequent stage.

Create a Data Source

The email parameter is part of the request you created. You can instruct ReadyAPI to automatically produce the parameter value.

Create a data source

  • Click the Generate Values button in the request editor.
     
example image 9

 

  • Select the request parameters that will be configured automatically in the Create Data-Driven Loop dialog:
     
example image 10
  • In the Data Source test stage, ReadyAPI will automatically add a property expansion that refers to the email property and a data source loop.
     
example image 11

 

  • Launch the test phase for the data source. As you can see, ReadyAPI has set the data source to automatically produce random email addresses as values for the email attribute.
     
example image 12

Test the data source

You can use the data log to test your data source:

  • Activate the Data Log panel.
     
example image 13

 

  • Click run, The ReadyAPI will query you for the number of rows you desire. Simply select OK.
     
example image 14

 

  • The log will include the retrieved data.
     
example image 15

 

You will add an assertion to the section's next step to verify test results.

Validate With Assertion

You can add an assertion to verify response data after setting up the Data Source test phase. We will employ Smart Assertion in this course, which is constructed automatically based on patterns found in responses.

The REST Request test phase, which makes use of data from a data source, should be included in your test case.

Get response

You must first replicate a request and obtain several sample responses before moving on. The information will be used by ReadyAPI to configure assertion properties automatically.

  • Click Run test case on the editor toolbar after switching to the test case editor:
     
example image 16

 

  • You can now construct an assertion.

Create an assertion

  • Click Smart Assertion in the REST Request window.
     
example image 17

 

  • Based on the most recent response, ReadyAPI will build an assertion and automatically set the required values for each data field. You can configure comparison operators and expected values, uncheck boxes to exclude specific fields from the assertion, and more. When finished, click Save:
     

example image 18
 

The Smart Assertion has been added to your test request. It will check to see if the response data corresponds to the predicted values. The additional assertion can be found in the Assertions panel:

Run the Test

You have a test step that uses a data source, a test case with a data source, and a data source loop that runs throughout the test. You can now execute your test case.

  • Click run on the test case toolbar to run the test case.
     
example image 19


You can view the details in the Transaction Log after the test run is finished. Click Transaction Log on the test case toolbar to achieve that.
 

example image 20


The specifics of the test case executed are shown below. The request test step was repeated by ReadyAPI and sent with various parameter values. The test case also passed because every execution succeeded.

Frequently Asked Questions

What is the Ready API used for?

API quality for Agile and Dev Ops software teams is sped up by Ready API, which enables teams to create, manage, and carry out automated functional, security, and performance tests through a single centralized interface.

How many types of Data Driven Function testing are there?

Here are a few common Data Driven Function testing: CSV (Comma-Separated Values) file types, Excel worksheets, tables in a database, script arrays, and table variables.

What are Environments in Ready API?

An environment in Ready API is a group of settings corresponding to a particular configuration for your tests. 

What are the major types of assertions available in ready API?

Assertions are used in Ready API Test tests to check response codes, response headers, specific values in response bodies, request execution time, and other things.

How are data driven function testing carried out?

In data driven function testing, test data and/or output values are read from data files rather than being pre-programmed with the same values each time the test is performed.

Conclusion

In this article, we have discussed the Data Driven Function testing in Ready API.

We hope this blog has helped you enhance your knowledge of Data Driven Function testing in Ready API. If you'd like to learn more, Check out the following links
 

 

Head to the Guided Path on the Coding Ninjas Studio and upskill in Data Structures and AlgorithmsCompetitive ProgrammingSystem Design, and many more courses.

If you want to Practice top Coding Problems, attempt mock tests, or read interview experiences, head to Coding Ninjas Studio, our practice platform

Live masterclass