Run Service Test Locally

Updated 3 months ago by Rahul Lahiri

So far, you have created a collection with the necessary test requests. Now we will convert the collection into a test suite, and run the test suite against the service running locally in the developer's laptop using auto-created mocks for the producer services.

Convert collection to test suite

  1. In API Studio, go to the API catalog. From the API catalog, select Collection from the Source dropdown, and then select the collection created earlier.
  1. Click on Save as test suite to convert the collection to a test suite. The default name assigned to the test suite created from the collection movieinfo_service_test will be GL_movieinfo_service_test.

Run test locally


Service testing locally requires the following steps:

  • Creating a test suite including mocks for egress requests
  • Service under test running locally
  • Forwarding the test requests from the cloud test driver to the service running locally
  • Setting up the decision rules to determine if the tests are successful

Mesh Dynamics uses a cloud-based test driver to send the test requests to the target. To run the test locally, you have to use a product like ngrok to generate a secure URL to your localhost server through any firewall. This provides the test driver an endpoint to send the test requests to.

While typically all producer services should be mocked during service tests, there may be cases where certain services must be live. API Studio's mock configuration management provides full flexibility to achieve this by simply changing the mock configuration from the UI.


  1. In the API editor, change the egress request configuration to use mock services for all egress requests.
  1. In API Studio, go to the Test Runner screen.
  1. Let us assume that you do not have a pre-defined configuration for the service test. From the Select Test Config dropdown, select Other.
  1. When the Test Config is set to Other, we assume that you will specify the endpoint. So we set the Test Instance to Other by default. Change it to use one of the predefined instances if necessary.
  1. Next we need to get an endpoint that the cloud test driver can send the requests to. Generate a secure endpoint using ngrok. We need to specify the port on localhost. In this example, the Eclipse IDE is configured to listen to port 8080.
    > ngrok http 8080
  1. In API Studio, configure the endpoint for the service test using the endpoint url from ngrok.
  1. In this example, we are assuming that there are no listeners deployed in the setup. All the API requests are only visible to the API Studio proxy. Select the Store to Datastore checkbox to save the API execution data to the Mesh Dynamics data store.
  1. Select the test suite: GL_movieinfo_service_test
  2. Select the service to test from the Select Service dropdown.
  1. Start the test by clicking the Run Test button.
  2. When the test finishes, the results will be available in the results section.

Note that for the first run, the pass/fail decisions are made based on default settings for the decision rules. After the first run, you can go in and update the decision rules to reflect your business needs.

Next, we will configure the service test to run in your test environment instead of locally. The tests can be initiated either from CI or from the API Studio UI.

How did we do?