Effectively Test Spring's RestTemplate with @RestClientTest

preview_player
Показать описание
Write effective tests for your HTTP clients using @RestClientTest to create a sliced Spring application context for testing.

This annotation also ensures to auto-configure a MockRestServiceServer to mock the HTTP response.

Рекомендации по теме
Комментарии
Автор

If you encounter any issue while running the test, try to remove the @Bean CommandLineRunner from the main application class. I forgot to mention this

rieckpil
Автор

Hi, how can i test timeout set on resttemplatebuilder, that we should have Connect Exception if timeout is exceeded?

tiyasha
Автор

is this @RestClientTest used for testing third party API? then what we can conclude from mocked responses?

AmNotLegend
Автор

What if I wasn't using getForObject but instead using exchange? How do I test that?

mrowox
Автор

Cool, but if you don't static import your DSL static methods, then you just add painful verbosity. You can recognize a need for a static import when the name of the class does not add anything to the meaning of the method name.

SirWolf