Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why we should use wiremock instead of Mockito

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?

like image 555
am10 Avatar asked Jun 06 '18 17:06

am10


1 Answers

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 :-)

like image 52
sauumum Avatar answered Oct 15 '22 23:10

sauumum