concept service test in category microservice

This is an excerpt from Manning's book Testing Microservices with Mountebank.
Let’s write a service test that validates that if the product catalog and content services return the given data, then the web façade will combine the data as shown above. Although mountebank’s HTTP API allows you to use it in any language, you will use JavaScript for the example. The first thing you will need to do is make it easy to create imposters from your tests. A common approach to make building a complex configuration easier is to use what is known as a fluent interface, which allows you to chain function calls together to build a complex configuration incrementally.
Though there’s some different terminology out there, I’ve used the term service test to describe a black-box test that validates your service’s behavior over the wire. Such tests do require a deployment, but you use service virtualization to maintain isolation from your runtime dependencies. This layer allows you to do out-of-process, black-box testing while maintaining determinism. Service virtualization enables you to remove nondeterminism from your tests by allowing each test to control the environment it runs in, as shown in figure 9.3.
You should be able to test the bulk of the behavior of your service through a combination of unit tests and service tests. They let you know that your service behaves correctly, assuming certain responses from its dependencies, but they don’t guarantee that those stubbed responses are appropriate. Contract tests give you validation that breaking-contract-level changes haven’t occurred (see figure 9.4). Service tests say, in effect, that if the service gets these responses from its dependencies, then it behaves correctly. Contract tests validate that the service does, in fact, get those responses. Good contract tests avoid deep behavioral testing of the dependencies—you should test them independently—but give you confidence in your stubs.
Service tests are postdeployment black-box tests of your application. Service virtualization ensures appropriate determinism.
Service tests should exercise your application over the wire, which rules out in-process stubs. This is where service virtualization shines, as service virtualization is the out-of-process equivalent of stubbing.
Although you can always set up your imposters using a config file, I recommend using mountebank’s API when possible for service tests. The API allows you to create the test data for each test separately rather than having to depend on an implicit linkage between a magic key in your test setup and the scenario you’re testing. You used mountebank’s API in chapter 2.