5. Run Tests

Applies to ReadyAPI 3.56, last modified on November 21, 2024

Let’s now check how the virtual service works and what responses it sends.

1. Start the virtual service

Before sending requests to the virtual service, we need to start this service. This will command ReadyAPI to simulate the virtual API.

To run the virtual service in our tutorial, simply click this button on the toolbar:

Service virtualization and API testing: Running the virtual service

In ReadyAPI, you can also deploy virtual services to remote computers and run them there. See Running Virtual Services for information on all the options.

2. Modify the test case

By default, the test case that we have in our ReadyAPI project sends requests to the live Currency Converter web service that resides at www.webserviceex.com. We need to modify it so that it sends requests to our virtual service. To do this:

  1. Select TestCase1 in the Navigator panel.

  2. Click the button on the toolbar and select the service URL from the drop-down list:

    Service virtualization and API testing: Setting the endpoint for test cases

    Click the image to enlarge it.

    ReadyAPI will apply this endpoint to all the requests that the test case simulates.

3. Run the test

OK, now, we can run the test case. To do this, click Run on the toolbar:

Service virtualization and API testing: Running the test case

Our test passed. To see detailed results, switch to the Transaction Log of the test case editor:

Service virtualization and API testing: Test case results

Click the image to enlarge it.

Note on test functioning

The test case and virtual service iterate through the same Excel sheet synchronously:

  • The test case inserts the values of the To and From columns into a request and sends this request to the virtual service. It does not forward the data cursor at this moment.

  • The virtual service reads the Rate column data from the data source and sends it in a response. Then, the service forwards its data cursor.

  • The test case uses an assertion in the Request test step to compare the received Rate value against the Rate value loaded from the data source. Then, the Data Source Loop test step in the test case forwards its data cursor.

This simple scheme works fine in the tutorial. However, if the synchronization breaks, the test case will fail. For instance, if you run the single request (not the test case), then the service’s data cursor will be ahead of the test case’s cursor. The comparison of the Rate values will fail and the test case will fail, as well. To avoid this, make sure to run the whole test case instead of the single requests, so the virtual API and functional test case will act as you expect them to, and, if needed, restart the virtual service to place its data cursor to the beginning of the data source.

Prev          Next

See Also

Data-Driven Virtual Services – Tutorial

Highlight search results