Setup and Teardown Script Editors

Applies to ReadyAPI 3.53, last modified on May 15, 2024

About

Setup and teardown scripts exist on the level of test case, test suite and project. They are executed before and after the run of an entity, respectively.

The editors support all the standard features of ReadyAPI scripting editors such as property expansions, code validation, and code templates.

Test case-level setup and teardown editors

Click the image to enlarge it.

Test suite-level setup and teardown editors

Click the image to enlarge it.

Project-level setup and teardown editors

Click the image to enlarge it.

Script objects

Below is a list of the default objects that are available in the setup and teardown script editors:

Object Description
virtRunner Includes methods and properties for running virtual services in ReadyAPI and VirtServer.
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.

testSuite Provides a scripting interface to the test suite run.
Note: This object is only available in test suite-level setup and teardown scripts.
testCase Provides a scripting interface to the test case run.
Note: This object is only available in test case-level setup and teardown scripts.
project Provides a scripting interface to the project run.
Note: This object is only available in project-level setup and teardown scripts.
context Provides a scripting interface to the test case, test suite, or project run, depending on the level.
testRunner Deals with test execution. The object includes methods and properties for running projects, test suites, test cases, and test steps, for getting test results, and more.

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.

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:

  1. Use the getClass() method that every object in ReadyAPI has to find the class name.

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

def className = context.getClass();
log.info(className);
Scripting editor: Get object class

Click the image to enlarge it.

Examples

Here are the links to examples of some scripts that can be run in the Setup and Teardown script editors:

See Also

Script Editors

Highlight search results