Every time when I need to mock some http requests my first choise is WireMock (which is actually standard for that I think), but today I discovered some alternative tool - MockWebServer.
What are pros and cons of WireMock vs MockWebServer?
Why We Should use WireMock Instead of Mockito? Wiremock provides a simulator for HTTP-based APIs while Mockito provides the mock implementation of the method/object.
WireMock is a library for stubbing and mocking web services. It constructs an HTTP server that we can connect to as we would to an actual web service. When a WireMock server is in action, we can set up expectations, call the service and then verify its behaviors.
WireMock is a mock server for HTTP-based APIs. Some might consider it a service virtualization tool or a mock server. It enables you to stub out an API or other external dependency you depend on to expedite local development. It supports testing of edge cases and failure modes that the real API won't reliably produce.
Note: When you specify this parameter, WireMock will still, additionally, bind to an HTTP port (8080 by default). So when running multiple WireMock servers you will also need to specify the --port parameter in order to avoid conflicts.
Basically MockWebServer
was invented to run smoothly on Android devices. There were several problems with WireMock
setup on Android and thats why MockWebServer
was invented.
If you use mocking on your backend though then I recommend WireMock
since it's more feature rich.
There is nice article on the topic here:
https://handstandsam.com/2016/01/30/running-wiremock-on-android/
especially My recommendation section
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With