Service Testing with Mesh Dynamics

Why service testing?

  • Allows independent testing of each service without being blocked by availability of producer APIs. New development can be tested earlier in the process.

  • Enables parallel development of services.

  • Service tests run faster compared to end-to-end tests.


Improves microservices developer productivity.

  • More efficient to diagnose root causes of test failures. The complexity and effort needed to debug and root-cause failures in end-to-end tests for microservices applications can be significant.

What is service testing?

In microservices applications, each service interacts with several producer services. Developers must ensure that their changes to a service do not disrupt any of the following:

  • Business logic of the service they changed

  • API interactions (contract & functionality) with the producer services the service depends on

  • API interactions its consumer services rely on

Testing the integration of each service with its immediate producers and consumers early helps detect functional and integration issues early.


Service testing is usually done by isolating the service under test, i.e. all the producer services are mocked during the test. Developers can rely on service tests to prevent any of the above disruptions. Service tests can be run by developers pre-submit, or run in the CI.

Service test creation challenges: Accurate API mocks

The primary challenge for service testing is the creation and maintenance of functionally accurate mocks. Mocks need to enable validation of contracts as well as functional correctness.

  • Creating mocks manually is extremely tedious.​ 

  • Mocks become stale as producer services change and requires ongoing effort to keep them current. If the process requires a high level of manual effort, then it is almost certain that the mocks will go stale and become inaccurate quickly.

A sustainable process should offer a high degree of automation for both creation and maintenance of functionally accurate mocks with minimal additional engineering burden.

  • Managing contracts as both producer and consumer services evolve independently.

  • Accurately representing expected values from producer services: Functional validation requires ensuring a variety of test cases, ideally exercising all code paths, with mocks that accurately represent the functionality of the producer services.

Service testing with Mesh Dynamics

Mesh Dynamics enables the creation of service tests with accurate mocks with minimal additional effort from the developers by following the steps below:

  • Configure the service being developed to send the egress requests to the target service via the Mesh Dynamics API Studio proxy. This allows Mesh Dynamics to capture every egress request along with the corresponding response. Learn more

  • Create test requests for the APIs exposed by the service, and create a collection with the test requests, corresponding egress requests and responses. Mesh Dynamics automatically creates API mocks for all egress requests. Learn more

  • Run the service test once locally and customize assertions. Learn more

  • Run the test suite locally or in CI for subsequent code changes. Learn more

Mesh Dynamics benefits

Mesh Dynamics helps improve productivity of microservices developers.

  • Efficient creation of service tests with auto-created API mocks

  • Test changes early even before submitting code

  • Test microservices in isolation without depending on all producers