Service Stub

  1. Motivation

    1. Removes dependence upon problematic services during testing

  2. Summary

      1. It actually mock original third party or remote services and generally used for testing and development purposes.

      2. It is also know as Mock Object.

  1. When to Use

      1. When you are using third party web services that are beyond yo control.

  2. Overview Tutorials

  1. Implementation

      1. Service stub is generally implemented with the help of Gateway.

      2. The Gateway is a Separated Interface rather than a class so you can have one implementation that calls the real service and at least one that's only a Service Stub.

      3. The desired implementation of the Gateway should be loaded using a Plugin.

      4. The key to writing a Service Stub is that you keep it as simple as possible—complexity will defeat your purpose.

  1. Example

      1. Mock Objects in Unit testing are good example of service stub pattern.

  1. Related Patterns

      1. Gateway

      2. Separated Interface

      3. Plugin

  1. Related Technologies

      1. Unit Testing Frameworks

  1. References

      1. None