We are using spring framework 5 and spring boot 2.0.0.M6 and we are also using WebClient
for reactive programming. We created test methods for our reactive rest endpoints and so I looked up for some example on how to do it. I found this one or this and many others which where all the same. They just autowire a WebTestClient
. So I tried the same:
@Log
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class MyControllerTest {
@Autowired
private WebTestClient webClient;
@Test
public void getItems() throws Exception {
log.info("Test: '/items/get'");
Parameters params = new Parameters("#s23lkjslökjh12", "2015-09-20/2015-09-27");
this.webClient.post().uri("/items/get")
.accept(MediaType.APPLICATION_STREAM_JSON)
.contentType(MediaType.APPLICATION_STREAM_JSON)
.body(BodyInserters.fromPublisher(Mono.just(params), Parameters.class))
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_STREAM_JSON)
.expectBody(Basket.class);
}
}
I cannot run this because I get the error:
Could not autowire. No beans of 'WebTestClient' type found.
So it does not seem that there is a auto configuration existing. Do I use the wrong version or what is the matter here?