title: Are Spring-Boot-Test @MockBeans supposed to qualify for @ConditionalOnBean conditions?
body: <p>I have a java <code>@Configuration</code> class with a <code>FOO @Bean</code> annotated with <code>@ConditionalOnBean(BAR.class).</code> As I expect this bean to be or not provided by the importer project, it's not present anywhere in my project.</p>
  
  <p>In my integration test, I mock <code>Bar.class</code> by means of <code>@MockBeans</code>. But for some reason Spring-Boot -debug tells me it did not found it so my conditional bean has not been loaded.</p>
  
  <p>I'm almost sure this situation has worked properly in the past, but did I configure anything extra? I can't manage to make it work </p>
  
  <p>P.S> I discovered that manually re-registering the @Bean in the same @Configuration as the conditional does not see it neither! Is there any known bug related to his?</p>
  
  <p>Autoreply: The culprit in this case is</p>
  
  <blockquote>
    <p>You need to be very careful about the order that bean definitions are
    added as these conditions are evaluated based on what has been
    processed so far. For this reason, we recommend only using
    @ConditionalOnBean and @ConditionalOnMissingBean annotations on
    auto-configuration classes (since these are guaranteed to load after
    any user-defined beans definitions have been added).</p>
  </blockquote>
  
  <p>P.S2> I realized Bar.class is an interface but I don't see why shouldn't it work as long as an implementation is present</p>
  
  <p><strong>P.S3> I found out that the MockitoTestExecutionListener is executed after the OnBeanCondition class. This seems my problem totally.</strong></p>