virtRunner Scripting Object

The virtRunner object allows you to run and stop virtual services (virtual APIs) specified in ReadyAPI or deployed on VirtServer.

Object Properties

Name

Description

exitCode

Returns the result of the previous run or stop method.

Object Methods

Name

Description

getExitCode

Returns the exitCode property.

run(virtName)

Runs the specified virtual service in ReadyAPI.

run(virtName, virtServerURL)

Runs the desired virtual service deployed on the specified VirtServer.

stop(virtName)

Stops the specified virtual service in ReadyAPI.

stop(virtName, virtServerURL)

Stops the desired virtual service deployed on the specified VirtServer.

Examples

Run and Stop the Virtual Service

The SOAP Sample Project shipped with ReadyAPI contains the Virtual Service Runner test steps at the beginning of each test case to run a virtual service, and at the end to stop it. For demonstration purposes, two scripts on the project level will substitute for all of these test steps. They will run the virtual service when you run the project and will stop it when the test finishes.

Important

With the approach described above, when you run a test suite or a test case, it will not run the virtual service, and your test will fail.

  1. Double-click the project node of the desired project in the Navigator.

  2. In the project editor, open the Setup Script tab and enter the following code:

    When you start the test run of the entire project, this script runs the specified virtual service before the test steps.

  3. Switch to the TearDown Script tab.

  4. Enter the following code:

    When the project run finishes, this script stops the specified virtual service.

If your test contains the Virtual Service Runner test step that runs or stops the same virtual service, you can disable it.

Run a Remote Virtual Service and Post Results to the Test Log

The following code snippet runs the desired virtual service deployed on the specified VirtServer. After that, it posts results of the virtual service run to the script log.

Like in the previous example, you can run this script in the Setup Script tab in the project editor.

See Also

Publication date: