Data Source and Data Sink Script Editors

Applies to ReadyAPI 3.56, last modified on November 21, 2024

About

You can generate values for data sources or store values to data sinks by executing Groovy scripts.

The editors support all the standard features of ReadyAPI scripting editors such as property expansions, code validation, and code templates.

Data source script editor

Click the image to enlarge it.

Data sink script editor

Click the image to enlarge it.

Script objects

Below is a list of the default objects that are available in the data source and data sink script editors:

Object Description
testRunner

Provides scripting interface to the test runner object that is executing the current test case and test step.

log

Includes methods and properties for posting messages to the Script log (to view this log, click Logs in the bottom left corner of the ReadyAPI window and switch to the Script log tab).

You use this for debugging and logging purposes: to post and view data in the log.

context

Provides a scripting interface to properties specific to the current test run.

result

An associative array, keys of which match the data source properties.

Note: This object is only available in the data source editor.
properties

An associative array, keys of which match the data sink properties.

Note: This object is only available in the data sink editor.

You can see methods and properties of these objects on the Code Completion list. To invoke it, type the object name and press Ctrl+Space.

To learn more about an object, find it in the API docs. API docs describe the internal structure of ReadyAPI; however, the names of objects used in the scripting editors are not necessarily the same as the names in the internal structure of ReadyAPI. To find an object in the documentation:

  1. Use the getClass() method that every object in ReadyAPI has to find the class name.

  2. Post the result to the Script Log using the log.info() method.

For example, for the context object the script will look like this:

Groovy

def className = context.getClass();
log.info(className);
Scripting editor: Get object class

Click the image to enlarge it.

Examples

You can find examples of data source scripts in the Groovy Data Source and Data Sink topics.

See Also

Script Editors
Data Sources and Data-Driven Tests

Highlight search results