Applies to ReadyAPI 3.0, last modified on November 19, 2019

ReadyAPI allows you to enhance your projects and tests with scripts. Scripts are available across ReadyAPI and can happen in many different cases:

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.

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

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

External Java libraries

ReadyAPI can load external libraries and work with classes from them. For this:

  1. Place your .jar to the <ReadyAPI>\bin\ext folder. The next time you start ReadyAPI, it will load the file as an external Java library that can be called from your scripts.

  2. Import the class to your script and call the method you need. Here is an example of using a simple class from the imported .jar file:

    Groovy

    import Sample // Import the Sample class

    Sample.add(1, 2) // Use the add method from the Sample class

Common scripting tasks

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

See Also

Groovy Script Test Step
Virtual Service Scripting
Script Libraries
Scripting

Highlight search results