ReadyAPI allows you to enhance your projects and tests with scripts. Scripts are available across ReadyAPI and can happen in many different cases:
Groovy Script test steps run as part of the functional test.
Setup and TearDown scripts run when you start or stop the related test item.
Report scripts run whenever the test generates a report.
Groovy Script data sources extracting and passing data as specified in code.
Virtual service Start, Stop, OnRequest, and AfterRequest scripts.
ReadyAPI events that provide additional flexibility in managing scripts and their triggers.
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.4.|
Currently, ReadyAPI supports the following languages:
ReadyAPI can load external libraries and work with classes from them. For this:
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.
If you address an external library in a virtual service that will be run in VirtServer, place the library in the <VirtServer>\bin\ext folder.
If you address an external library in a load test that will be run on a LoadUI agent, place the library in the <LoadAgent>\bin\ext folder.
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:
import Sample // Import the Sample class
Sample.add(1, 2) // Use the add method from the Sample class
Here are some common ways to improve tests by using scripts:
Create Groovy Script test steps to add various enhancements to a functional test case.
Create script assertions for REST, GraphQL, or SOAP responses.
Enable the setup and teardown scripts to use them during the initialization and cleanup on the project, test case, or test suite level, or in load tests.
Enable the startup, shutdown, Before Request, and After Request scripts to perform initialization, cleanup, or dispatch and handle requests to the virtual API.
Enhance plugins and extend their functionality.
Centralize common scripts with Groovy Script libraries.
Generate data for test cases with data source scripts.
Save the test case run data with data sink scripts.
Generate property values dynamically with DataGen script properties.