title: WebTestClient not injected
body: <p>First of all I'm new to the java stack and in my defence I might ask something stupid, thank you for your patience!</p>
  
  <p><strong>What I need:</strong></p>
  
  <p>Integration test but without the external requests being made. That means I have to mock a dependency somewhere deeper in the stack than a normal unit test.
  I also don't want to load all the stack in the context.</p>
  
  <p><strong>Expected:</strong></p>
  
  <p>Be able to mock only the client with @BeanMock and have the test pass. (From my trials this only mocks the first level in depth).</p>
  
  <p><strong>Actual:</strong></p>
  
  <p>With the current setup I'm getting</p>
  
  <p><code>Error creating bean with name 'com.example.demo.SomeControllerTest': Unsatisfied dependency expressed through field 'webClient'</code></p>
  
  <p>If I use <code>@WebFluxTest(SomeController.class)</code> and <code>ContextConfiguration(...)</code> the client ends up being null. If I then add the <code>@TestConfiguration</code> webflux is complaining about having some annotations in conflict <code>@Configuration</code> for example.</p>
  
  <p>Any ideas are greatly appreciated!</p>
  
  <pre><code>@RestController
  public class SomeController {
    private final SomeService someService;
  
    @Autowired
    public SomeController(SomeService someService) {
      this.someService = someService;
    }
  
  
    @GetMapping(value = "/endpoint")
    public Mono&lt;String&gt; endpoint() {
      return someService.get();
    }
  }
  
  
  @Service
  public class SomeService {
    private final Client client;
  
    @Autowired
    public SomeService(Client client) {
      this.client = client;
    }
  
    public Mono&lt;String&gt; get() {
      return client.build().get().retrieve().bodyToMono(String.class);
    }
  }
  
  
  @Component
  public class Client {
    private final HttpServletRequest request;
  
    @Autowired
    public Client(HttpServletRequest request) {
      this.request = request;
    }
  
    public WebClient build() {
      return WebClient.builder()
        .baseUrl("https://httpstat.us/200")
        .build();
    }
  }
  
  @RunWith(SpringRunner.class)
  @TestConfiguration
  @SpringBootTest(classes = {
    SomeController.class,
    SomeService.class
  })
  @AutoConfigureWebTestClient
  public class SomeControllerTest {
    @Autowired
    private WebTestClient webClient;
  
    @MockBean
    private Client client;
  
  
    @Before
    public void setUp() {
      when(client.build())
        .thenReturn(WebClient.create("https://httpstat.us/201"));
    }
  
    @Test
    public void deepMocking() {
      webClient.get()
        .uri("/endpoint")
        .exchange()
        .expectStatus().isOk()
        .expectBody(String.class).isEqualTo("201 Created");
    }
  }
  </code></pre>