Skip to main content

What is Smocker?

Smocker (server mock) is a simple and efficient HTTP mock server.

The goal of Smocker is to help you mock the HTTP dependencies of your application. It's a great tool for integration tests automation.

Smocker really shines in a microservice environment with an API gateway. On your development or test infrastructure, you just need to deploy it instead of your API gateway and have your application use it as the gateway.

Production environment, with an API gateway

Your Application
Microservice 1
Microservice 2
Microservice 3
API Gateway
External Service

Test environment, with Smocker

forward request
Mocked Microservice 1
Smocker
Mocked Microservice 2
External Service
Your Application
Microservice 3

Smocker can also be used as an HTTP proxy through the commonly used http_proxy environment variable.

Production environment

External Service
Your Application
Microservice 1
Microservice 2
Microservice 3

Test environment, with Smocker using http_proxy

transparent-2
transparent-1
forward request
forward request
http_proxy
External Service
Microservice 3
Smocker
Mocked Microservice 1
Mocked Microservice 2
Your Application

Smocker provides several powerful ways to setup your testing environment:

  • Static mocks return a static response for a given request. It's the most basic behavior of Smocker,
  • Dynamic mocks return a response with variable parts. Dynamic mocks can be declared using Go templates or Lua,
  • Proxies just forward the request to an actual server, because mocking is not always suitable for testing.

Smocker also has a great user interface which we use extensively to write tests iteratively.

Smocker's user interface - Mocks

Smocker's user interface - History