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.
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
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.
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
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
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
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
You can utilize the grid’s toolbar in the following ways-
Delete rows – Deletes the selected rows.
Insert rows – Inserts several rows before the selected row.
Clear Cells – Removes contents of the selected cells.
Fill Down – Duplicates the selected cell's value to the cells below.
Fill Right – Duplicates the selected cell's value to the cells on the right.
Select All – Checks all the rows.
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-
To begin with, you need to create the File and Size properties in the data source.
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];
}
JSON
The JSON data source uses the JSONPath to parse the input JSON expression.
Configuration
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
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
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.
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.