Scripting

Applies to ReadyAPI 3.5, last modified on January 19, 2021

ReadyAPI includes integrated Groovy components and an extensive API allowing you to use scripts to enhance tests and extend the ReadyAPI functionality. You can also create your own modules and reuse them in multiple projects.

Most commonly, scripts are used to prepare your environment before running a test and remove any aftereffects of the test when it finishes. For example, you can start virtual services before starting your test and stop them once the testing is over.

Scripts are available across ReadyAPI and can happen in many different cases:

Common scripting tasks

Here are some common ways to improve tests by using scripts:

You can find some examples of script usage in the Groovy Scripts section.

Supported languages

You can select the scripting language to be used in the project properties. We recommend using Groovy scripts in your tests, since ReadyAPI offers code completion and debugging of Groovy scripts.

Currently, ReadyAPI supports the following languages:

 Groovy 2.4.17 http://groovy-lang.org/
 Rhino JavaScript 1.7.10 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Documentation
The Project Properties panel

Libraries and script collections

The Groovy editors in ReadyAPI give you access to several types of scripting objects:

To learn more about customizing your scripting needs, see the Script Libraries section.

Scripting also allows you to access objects of ReadyAPI itself. For a reference to the internal structure of ReadyAPI, see API docs.

ReadyAPI uses a number of third-party libraries. It is quite possible that we will update some of these libraries or even remove them from ReadyAPI. If you use classes from these libraries, you will have to update your scripts. See a list of third-party libraries updated in ReadyAPI 3.5.1.

Editor features

ReadyAPI script editors support code completion for Groovy. As you type code, available methods and parameters will appear in a drop-down list, so you can select them and speed up the code writing.

Scripting editors also offer code validation and code templates. You can also use property expansions to insert data from other test steps into your scripts.

For details about editor features, see Script Editors.

Debugging

ReadyAPI allows debugging scripts only in the Groovy Script test step. To learn more about the process and its limitations, see the Groovy Script Test Step topic.

See Also

Functional Testing

Highlight search results