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.

  3. When to Use
    1. When you are using third party web services that are beyond yo control. 
  4. Overview Tutorials
    1. http://martinfowler.com/eaaCatalog/serviceStub.html
  5. 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.
  6. Example 
    1. Mock Objects in Unit testing are good example of service stub pattern.
  7. Related Patterns
    1. Gateway
    2. Separated Interface
    3. Plugin
  8. Related Technologies 
    1. Unit Testing Frameworks
    2. Moles
  9. References
    1. None