If WebFlux is on the classpath it would be cool if MockRestServiceServer could be configured with a WebClientinstred of a RestTemplate.

Since both will be on the classpath (RestTemplate is in a shared module), the annotation should probably have an attribute to indicate a preference. Not sure that both can be used at the same time though.

@RestClientTest(useWebClient=true)

An enum will be better but I can't find good names for the values (REST_TEMPLATE is pretty gross).

This currently requires some changes in Spring Framework, I've created an issue

Comment From: mickaeltr

Hello,

Does anyone has any update on this one?

I was about to migrate my code to WebClient as recommended, because RestTemplate / OAuth2RestTemplate are in maintenance mode… but the lack of testing support makes it inconvenient in the end.

Using MockWebServer is an option, but it's not as elegant as RestClientTest.

Thanks

Comment From: wilkinsona

The Spring Framework team have declined the issue that was blocking this one. Their recommendation is to use MockWebServer. Given that's the situation, there's nothing that was can do here.

Comment From: mickaeltr

Thanks for the insight @wilkinsona

Comment From: jbotuck

Can you have the slice autoconfigure a webclient and an okhttp server?

Comment From: philwebb

@jbotuck Please ask questions on stackoverflow.com or gitter.im. We prefer to keep the issue tracker for bugs/enhancements only.

Edit: Actually, I see this was also raise in #35337

Comment From: jbotuck

Sorry if I'm having trouble navigating this. This wasn't a question as much as a feature request. The current issue concludes with : won't support a test slice for webclient since the spring mock Web server doesn't support webclient

I'm here to ask for a test slice that uses okhttp mock server instead.

This might be worthy of its own GitHub issue, but as you saw, I tried that already.