title: Overriding a dependency in a Micronaut test
body: <p>I'm testing a Micronaut class that has a bean injected into it. In my test I provide a <code>@MockBean</code> class to override it. However, it seems Micronaut still injects the real dependency.</p>
  
  <pre><code>@MicronautTest
  public class ClassUnderTestTest {
  
      @Inject ClassUnderTest classUnderTest;
  
      @Test
      public void test() {
  
      }
  
      @MockBean
      Dependency dependency() {
          return mock(Dependency.class);
      }
  
  }
  </code></pre>
  
  <p>I uploaded a minimum repro to Github: <a href="https://github.com/crummy/micronaut-test-dependencies" rel="noreferrer">https://github.com/crummy/micronaut-test-dependencies</a> . The real dependency throws an exception, and the test does too. I would not have expected this to happen because of my <code>@MockBean</code>.</p>
  
  <p>If I change the annotation to be <code>@MockBean(Dependency.class)</code> then I get this error: <code>Message: No bean of type [di.failure.example.Dependency] exists</code>. This seems even more confusing to me - now it doesn't resolve my real or my mock dependency?</p>