I am having Restclient
class which makes a rest call to URL whenever GET method is called on the Restclient
object. I have a proper logic working behind.
Now Consider a case instead of using wiremock I used Mockito to mock the method GET on the Restclient
object to return the appropriate response.
Does this have a disadvantage like the amount of code covered from the main module or both are equally good?
Wiremock
provides a simulator for HTTP-based APIs while Mockito
provides the mock implementation of the method/object.
If we are using Mockito to mock HTTP-based method, it means we are trying to return the object/response without testing any code to invoke REST service, getting HTTP response and deserializing the same.
If we use the Wiremock
, we will able to test close to reality as it will test invocation of REST call as well as deserialization of the response.
https://www.linkedin.com/pulse/what-difference-between-stub-mock-virtual-service-wojciech-bulaty/ is one good article to read, of course not by me :-)