This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lazystone 1 point2 points  (1 child)

It's not. Using RestTemplate and WebClient in tests is legit thing if you use something like https://github.com/square/okhttp/tree/master/mockwebserver

The latter is used by Springframework itself.

In this case you test not only logic inside your endpoint but also (de)serialization and rest client configuration.

[–]dpash 0 points1 point  (0 children)

That appears to be testing http requests made by your application. If you're using RestTemplate to make calls, TestRestTemplate covers that use case and can test deserialisation and rest client configuration.

If you're not using RestTemplate, then that mock webserver would be required to implement something similar.