Thursday, October 17, 2019

Mocking rest services with Mockito and MockRestServiceServer in Spring

https://www.baeldung.com/spring-mock-rest-template

the code in the article is broken, here https://github.com/vernetto/mockrest you find a fixed version.

It's very simple and elegant solution.

You see @InjectMocks and @Mock annotations in action. Here they are explained https://www.baeldung.com/mockito-annotations

Here the javadoc of https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/test/web/client/MockRestServiceServer.html

No comments: