Introduction
ReadyAPI is an automation testing tool used by developers and testers to validate the backend application. ReadyAPI allows us to manage, create, and execute automated performance, functional, and security, tests in one centralized interface. It is a no-code API testing platform that is designed to simplify your testing workflows.
In this article, we will be going through the setup, requirements, and UI references in ReadyApi. Also, we will explore the various pages and editors available under the ReadyAPI Functional Tests node.
So, let's get started with the article to cover the setup, requirements, and UI references in ReadyApi.
Setup, TearDown, and Report Scripts
Setup is the first and important part among all the three Setup, requirements, and UI References in ReadyAPI. We can use the Setup, TearDown, and Report scripts for enhancing the test items’ functionality for the ReadyAPI. In this section, we will learn about all three scripts in detail.
Setup and TearDown scripts
Setup and Teardown scripts are available in all test items, including projects, test suites, and test cases. The test engine runs its Setup script before performing each test item. When the test item run is over, the test engine executes its TearDown script.
For setup and teardown scripts we have the following scripting objects:
- virtRunner:– It is the object used for controlling virtual services.
- log:– This object is used for interaction with the log.
- context:– The context object contains various data from the current test. For example, properties.
-
testRunner:– It is the interface of the test runner.
We can edit the setup and Teardown scripts for the project, test suite, and test case in the editor in the Setup and TearDown tabs.
Let’s see an example of editing the script for a test case run to understand better. In this example, we will learn how to reset properties at test run start.
// To get the default value from the project property
def value = testRunner.testCase.testSuite.project.getPropertyValue("defaultValue")
// To set the test case property to the default value
testRunner.testCase.setPropertyValue("my property", defValue)
// Clear the property value
testRunner.testCase.setPropertyValue("empty property", "");
The above groovy code is a setup script which resets the project properties to the default value fro a test case run.
Report script
The Report script is available for test cases and test suites. The test engine performs the Report script of a test item when we generate a report for it.
For the report script we have the following scripting objects:
- log:– This object is used for interaction with the log.
- report:– It is the object that contains all of the data that is utilised to populate the report. Its members enable us to add or modify data and subreport data used by the report engine to populate the report template.
-
params:– It is the object that contains all the defined report parameters with their values.
We can edit the script for the test case and test suit in the Report tab as shown in the image below.