Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Data Connection 
2.1.
Configuration
2.1.1.
Prepared Properties
2.1.2.
Connection
2.1.3.
Configure
2.1.4.
TestConnection
2.1.5.
SQL Query
2.1.6.
Fetch Size
2.1.7.
Stored procedure
2.1.8.
Build Query
3.
Data Generator 
3.1.
Available Generators
4.
Excel 
4.1.
Configuration
4.1.1.
File 
4.1.2.
Worksheet
4.1.3.
Start at Cell
4.1.4.
Ignore Empty
4.1.5.
Evaluate Formulas
5.
File 
5.1.
Configuration
5.1.1.
File 
5.1.2.
Separator
5.1.3.
Charset
5.1.4.
Trim
5.1.5.
Quoted Values
6.
JDBC 
6.1.
Configuration
6.1.1.
Properties
6.1.2.
Prepared properties
6.1.3.
Connection
6.1.4.
Configure
6.1.5.
Driver
6.1.6.
Connection String
6.1.7.
Password
6.1.8.
Test Connection
6.1.9.
SQL Query
6.1.10.
Fetch Size
6.1.11.
Stored Procedure
6.1.12.
Use as a wizard
7.
Grid 
7.1.
Configuration
8.
Groovy 
8.1.
Configuration
9.
JSON 
9.1.
Configuration
9.1.1.
Source Step
9.1.2.
Source Property
9.1.3.
RowPath
9.1.4.
ColumnPath
10.
XML
10.1.
Configuration
10.1.1.
Source Step
10.1.2.
Source Property
10.1.3.
Row XPath
10.1.4.
Column XPath
11.
Directory
11.1.
Configuration
11.1.1.
Directory
11.1.2.
Filename Filter
11.1.3.
Encoding
12.
Prepared properties 
13.
Query Wizard
14.
Frequently Asked Questions 
14.1.
What is the prerequisite for studying Data source types in ReadyAPI?
14.2.
What does “ignore empty” do?
14.3.
How are the properties matched in JDBC Data Source?
14.4.
Name some objects used in Groovy Script.
14.5.
Can we use XML data source types in virtual tests?
15.
Conclusion
Last Updated: Mar 27, 2024

Data Source types in Ready API

Author Geetika Dua
0 upvote

Introduction

Ready API consists of vital components for creating comprehensive tests of API and web services. You can create Functional, Virtual, and security tests with the help of ReadyAPI.

Intro

We will discuss the various settings of data source types present in ReadyAPI.

Data Source Description
Data Connection Obtains Data from a database using a JDBC connection.
Data Generator Generates the data using a built-in engine
Excel Obtains data from Excel
File Obtains data from file
JDBC Does the same job as Data connection. The only difference is that it uses a specified connection.
Grid Gets data listed in a grid
Groovy Lists data using a groovy script
JSON Parses the data with JSON content
XML Parses the data with XML content 
Directory Searches for a specific directory and gets data

 

Data Connection 

The Data Connection data source obtains data from the database using a JDBC Data Connection. The JDBC connection is predefined. We just need to set up one link for virtual and functional tests.

The data source declares values to the properties whose names coincide with the names of the database columns.

Configuration

data connection

Prepared Properties

There is a table that enlists prepared properties used in SQL queries.

Connection

Informs the name of the database connection.

Configure

Gives access to the database configuration dialog to change or modify the current database connection.

TestConnection

Tests the existing Database connection.

SQL Query

A query to the database

Fetch Size

Tells the number of rows in one database roundtrip

Stored procedure

Use this query if you want to access a stored procedure.

Build Query

It opens the Build Query dialog box.

Data Generator 

The Data Generator Source is used to generate properties of various data types. This is an upgradation of creating the properties manually.

data generator

Available Generators

Name of the Generator It generates-
Boolean True or False
City City Names
Computer Address IP address or MAC address
Country Name of the country
Custom String String with Optional Generators
Date and Time Date and time values
Email Email Address
GUID GUIDs
Integer Random Integer
Name  Human Names
Phone Number Random Phone Numbers
Real Random Real Numbers
Social Security Number Random Security Number
State Random States of US
Street Address Street Addresses
String Random Strings

 

Excel 

The Excel data source retrieves data from a Microsoft Excel File. It follows a pattern of picking the information from columns and setting them as properties.

Values of the first column are given to the first property; the second value is given to the second property, and so forth.

Configuration

excel

File 

Displays the name of the specified excel file.

Worksheet

It is the name of the worksheet.

Start at Cell

It notifies about the starting of the cell.

Ignore Empty

ReadyAPI ignores the cells without data if stated.

Evaluate Formulas

ReadyAPI executes formulas before execution.

File 

The file data source obtains data from the text documents. It assesses the data line by line and assigns the properties according to the sequence in the comma-separated file. When you import a CSV file, ReadyAPI will create properties for the values from the file.

For TXT files, you have to make all properties manually.

Configuration

file

File 

States the name of the file.

Separator

States the character used for separating.

Charset

Gives information about the encoding.

Trim

It specifies the removal of trailing or leading spaces.

Quoted Values

Tells whether ReadyAPI should ignore the quoted text.

JDBC 

The JDBC(Java Database Connectivity)data source obtains data from the database through the test step's connection. The data source either uses a project database connection or a connection defined only for the data source. The data source appoints values to the properties by referring to the names of the database columns.

Configuration

jdbc

Properties

This is a table that contains the properties of the data source.

Prepared properties

This is a table that has prepared properties used in the SQL Query

Connection

Lists the name of the database connection.

Configure

It opens the Database configuration dialog to change or modify the selected database connection.

Driver

Lists the driver for the connection.

Connection String

Tells about the used connection string

Password

Specifies the password.

Test Connection

Ensures the link to the database. 

SQL Query

Mentions the query to be executed.

Fetch Size

It retrieves the number of rows.

Stored Procedure

This option is checked if the query is a call to the stored procedure

Use as a wizard

It opens the SQL query dialog box; if the query is stored, the stored procedure starts; otherwise, the build SQL dialog opens.

Grid 

The data source stores data inside ReadyAPI without depending on external storage. Each column of the grid relates to a particular property. When it reaches the end of the grid, it starts again from the top and repeats the process.

Configuration

grid

You can utilize the grid’s toolbar in the following ways-

  1. Delete rows – Deletes the selected rows.
  2. Insert rows – Inserts several rows before the selected row.
  3. Clear Cells – Removes contents of the selected cells.
  4. Fill Down – Duplicates the selected cell's value to the cells below.
  5. Fill Right – Duplicates the selected cell's value to the cells on the right.
  6. Select All – Checks all the rows. 
  7. Select None – Unchecks all the rows.

Groovy 

The groovy data source uses the groovy script to generate a property.

Configuration

Define the groovy code that helps to generate the data.

An example would convey the idea in a better way.

Consider that you want your data source to return names and sizes of files in the home directory. Follow these steps-

  1. To begin with, you need to create the File and Size properties in the data source.
  2. Change the data source type to Groovy, paste the code, and click on the run.
// Import the class
import groovy.io.FileType
// Get the row you are working on
def row = testRunner.testCase.testSteps["Data Source"].currentRow;
def NameofFolder = System.getProperty("user.home");
// An array that contains the name of files
def NamesofFile = [];
// An array that contains the size of files
def SizesofFile = [];
// List of the files
new File(NameofFolder).eachFile(FileType.FILES)
{
    // Add file information to the arrays
    file -> {
        NamesofFile.add(file.name);
        SizesofFile.add(file.size().toString());
    } }

// Check the size restrictions
if (row < NamesofFile.size) {
    result["File"] = NamesofFile[row];
    result["Size"] = SizesofFile[row];
}

 

groovy

JSON 

The JSON data source uses the JSONPath to parse the input JSON expression.

Configuration

json

Source Step

Test step that contains JSON property to refer to.

Source Property

Tells the property that contains JSON Data.

RowPath

It is the JSONPath expression that returns an array element. 

ColumnPath

ReadyAPI applies JSONPath expressions to the JSON structure returned by the JSONPath expression specified in the Row Path.

XML

The XML data source uses XPath Expression to fetch data from a property containing XML. We can not use the data sources of XML type in virtual tests.

Configuration

xml

Source Step

Specifies a test step that contains the XML property to read from.

Source Property

Defines the name of the property that contains XML Data.

Row XPath

The XPath expression selects a set of elements from rows.

Column XPath

XPath expressions that give the required property values.

Directory

The Directory data source moves through the files within the specified directory and puts the files' content to the first property defined in the Properties panel.

The data source assigns data to the first property in the list. Other properties will be blank, except for fileName.

Configuration

directory

Directory

The directory has the job of scanning the files.

Filename Filter

Defines an expression to read only filtered files. Like *XML will just read XML files.

Encoding

Declares encoding to read the files.

Prepared properties 

We can add variable names to queries using Prepared Properties in JDBC and Data connection.
 

pp
property

Query Wizard

You can use the Query Wizard to create JDBC database queries. It gives access to a visual interface and helps you set up some basic filtering rules.

You can configure it by adding the query into the database table, and it can be configured by using a table that contains several features like output, expression, aggregate, etc.

Frequently Asked Questions 

What is the prerequisite for studying Data source types in ReadyAPI?

Before dwelling on Data sources, you must be familiar with Data-driven testing.

What does “ignore empty” do?

If we check this option, ReadyAPI ignores the rows with no data.

How are the properties matched in JDBC Data Source?

The data source appoints the values to the properties by referring to the names of the database columns.

Name some objects used in Groovy Script.

Context, result, testRunner, and log are some objects used in Groovy Script.

Can we use XML data source types in virtual tests?

No, we can only use XML data types in functional tests. They don't work for virtual tests.

Conclusion

In this blog, we studied the details of Data Source types in ReadyAPI. You may refer to the official documentation for further information on the topic.

For more information on ReadyAPI, refer to.

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