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.
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.
|
||
properties |
An associative array, keys of which match the data sink properties.
|
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.
Object reference
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:
-
Use the
getClass()
method that every object in ReadyAPI has to find the class name. -
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
log.info(className);
Examples
You can find examples of data source scripts in the Groovy Data Source and Data Sink topics.