Scripting

Applies to ReadyAPI 3.8, last modified on May 05, 2021

In ReadyAPI, you can 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 Scripting Samples section.

Supported languages

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

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.

The Project Properties panel

Libraries and script collections

Scripting 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.

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.8.

Object reference

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

Each scripting editor has its own set of objects imported by default. You can learn more about them in the respective topics:

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.

Samples

You can find examples of how to perform certain tasks using scripts in this section:

Groovy Scripting Samples

See Also

Functional Testing
Script Extensions (Reporting)

Highlight search results