title: Mocking a bean in a Spring context
body: <p>I want to test a Spring bean <strong>A</strong>, of course this bean is part of a<br>
  context and it uses other beans to carry out operations.</p>
  
  <p>There is a particular bean <strong>B</strong> in the context that I want to mock for this test, and note that <strong>B</strong> is not injected to <strong>A</strong> (I could handle this case easily with <code>@InjectMocks</code> and <code>@Mock</code> annotations), <strong>B</strong> is injected to <strong>C</strong> that is injected to <strong>D</strong>, that is injected to <strong>A</strong>.</p>
  
  <p>Can I mock only <strong>B</strong> while testing class <strong>A</strong>?
  How can you accomplish this ?</p>