So we have seen Hoverfly and Wiremock API Simulations tools earlier and looked at Java examples of using them. Lets look at how both of them compare on various parameters and which one is best fit for your use-case.
We will do a comparison based on the few parameters as below and look at limitations and advantages over each other
As it acts as forward proxy HTTPS is directly to and fro actual end-point. It also requires client to support the HTTP protocol to make the initial connection.
We will do a comparison based on the few parameters as below and look at limitations and advantages over each other
- Support for Capture Replay : Ability to capture the requests once and replay them during simulation
- Support for HTTPS : Support for Https based API's
- Client Side required changes : Changes required at the client, if any
- Support for Stateful API's : Support for states when using stateful API's
- Support for Response Templating : Ability to templatize responses to give dynamic behavior
- Miscellaneous : Other miscellaneous parameters and unique features
Hoverfly
Hoverfly released under Apache 2.0 license primarily written using Go language is developed and maintained by SpectoLabs.
Support for Capture Replay
Capture is only supported in Proxy mode and is not supported in Web-Server mode. The captured requests can be exported to a Json file. Hoverfly has clear, defined and documented Simulation Schema.Support for HTTPS
Proxy mode has the support for capture, simulate HTTPS API's and can use custom generated certificates for authentication. The Web-Server mode does not support HTTPS.As it acts as forward proxy HTTPS is directly to and fro actual end-point. It also requires client to support the HTTP protocol to make the initial connection.
Client Side Changes
The client used should support and honor the 'Proxy Settings' that needs to be configured for using the tool. As the capture works in forward proxy no changes are required on the client side.
Support for Stateful API's
Hoverfly supports simulation of stateful API's. You can define states and give each requests a current state for matching and next transition state to move to the new state.
Support for Response Templating
Hoverfly supports response templatization to build dynamic responses. It comes with few predefined helper templates and uses a library based on handlebars for templating.
Miscellaneous
- One of the main features of hoverfly is use of forward proxy. It allows to run in what is called as SPY mode where few API call can be simulated while the non-matching ones can call the real API.
- Supports multiple endpoints for capture/simulation.
- Has support for importing/resetting simulations at runtime.
- Ability to capture all the headers or specific mentioned headers
- Provides Python and Java bindings
- Allows Man in the Middle behavior for both HTTP and HTTPS through the use of middleware mode
- Documented Simulation Schema
Wiremock
Wiremock also released under Apache 2.0 license is written in Java, developed and maintained by Tom AkehurstSupport for Capture Replay
Capture is supported and there is the old (legacy) as well as the new way to capture the requests. Captured requests can be exported in Json file. Each request is exported to a separate file.Support for HTTPS
Wiremock provides support for HTTPS and can use custom generated certificates for authentication. As it acts as reverse-proxy the actual end point is HTTPS details are hidden. The wire-mock server acts as the endpoint for the client.Client side changes
The endpoint should be changed to point to wiremock server which can act as the reverse proxy for the actual endpoint during the capturing of requests.Support for Stateful API's
Stateful API's are supported through Scenarios. You can define Scenario names and the different states in the scenarios which the request will match and transition during simulation. The legacy method of capture does not support stateful capture.Support for Response Templating
Templatization is supported through the handlebars library. It contains the string and other helpers provided by the Java implementation of handlebars by jknackMiscellaneous
- Due to reverse proxy nature the clients are independent of the protocol of the actual endpoint
- Has support for forward-proxy via enable-browser-proxy
Final Thoughts
So now that we have looked into both the tools lets look at what are few advantages and limitations over each other. The list is in no way complete but can act as a quick guide to identify which tools better fits your use-case.
Hoverfly Advantages
- Support for SPY Mode where few API's are simulated while others are passed to the real endpoint
- Defined and Documented Simulation Schema
- Run-time importing/resetting of the simulations
- Supports multiple endpoint with single instance (at-least in the proxy mode)
Hoverfly Limitation
- Cannot capture requests in webserver mode
- Web-server mode does not support HTTPS
- Dependent on the client for support and use of system/manual proxy settings
Wiremock Advantages
- Independent of the protocol of the actual endpoint
- No configuration/changes required by the client.
Wiremock Limitations
- Runtime import/resetting of simulations not supported. Simulation mappings needs to be defined at the start during creation/initialization.
- Cannot capture all headers. Needs a list of the headers that needs to be captured.
- Simulation Schema though defined is not documented completely anywhere.
- Only one endpoint can be used with one instance. (Capture needs to be specified with a target url).
No comments:
Post a Comment