title: Mock dependency with ApplicationContextRunner in SpringBoot Test result into UnsatisfiedDependencyException
body: <p>I have following class, which publishes the spring event.</p>
  <pre><code>@Component
  public class ApplicationReadyEventListener {
      Boolean isHit = false;
  
      @EventListener
      public void handle(final ApplicationReadyEvent applicationReadyEvent) {
  
  applicationReadyEvent.getSpringApplication().getClass().toGenericString()));
          isHit = true;                              // This needs to be replaced with CustomLoggerComponent
      }
  }
  </code></pre>
  <p>As I need to publish the event and need to check failure and success event, I have following test:</p>
  <pre><code>@ExtendWith({SpringExtension.class})
  class ApplicationReadyEventListenerTest {
  
  
      private final ApplicationContextRunner runner = new ApplicationContextRunner();
  
  
  //Success Test 
  @Test
      void loggerShouldLogWhenApplicationIsReady() {
          SpringApplciation application = new SpringApplication(ApplicationReadyEventListener.class);
  
          application.setWebApplicationType(WebApplicationType.NONE);
          final ApplicationReadyEvent event = new ApplicationReadyEvent(application, null, mock(ConfigurableApplicationContext.class));
          runner.withBean(ApplicationReadyEventListener.class)
                .run(context -&gt; {
                    context.publishEvent(event);
  
                    final ApplicationReadyEventListener applicationStartedListener = context.getBean(ApplicationReadyEventListener.class);
                    MatcherAssert.assertThat(applicationStartedListener.isHit(), is(true));
                });
      }
  
  //FailureTest 
      @Test
      void shouldNotCallApplicationStarted() {
   SpringApplciation application = new SpringApplication(ApplicationReadyEventListener.class);
          application.setWebApplicationType(WebApplicationType.NONE);
  
          final RuntimeException runtimeException = new RuntimeException(&quot;Some Error Occurred&quot;);
          final ApplicationEvent event            = new ApplicationFailedEvent(application, null, mock(ConfigurableApplicationContext.class), runtimeException);
  
          runner.withBean(ApplicationReadyEventListener.class)
                .run(context -&gt; {
                    context.publishEvent(event);
  
                    final ApplicationReadyEventListener applicationStartedListener = context.getBean(ApplicationReadyEventListener.class);
                    MatcherAssert.assertThat(applicationStartedListener.isHit(), is(false));
                });
      }
  
  }
  </code></pre>
  <p>This is working fine as of now as the class (ApplicationReadyEventListener) does not have any bean. I want to have a custom logger for this one, and instead of isHit, I would be checking the side effect of custom logger's method getting called.</p>
  <p>However, I could not add any dependency, so I tried to isolate the problem by creating a separate application which contains the subject under test <code>ApplicationReadyEvent</code> and to have CustomLoggerBean created, used following one:</p>
  <pre><code>@Configuration
  public class CustomLogMockProvider {
  
      @Bean
      public  Logger logger() {
          return Mockito.mock(Logger.class);
      }
  }
  </code></pre>
  <p>And when I write this test for the same:</p>
  <pre><code>   @Test
      void tesCustomLoggerBeanPresence() {
          SpringApplciation application = new SpringApplication(CustomLogger.class);
  
          application.setWebApplicationType(WebApplicationType.NONE);
  
          runner.withBean(CustomLogMockProvider.class)
                  .run(context -&gt; {
  
                      String[] beanNamesForType = context.getBeanNamesForType(Logger.class);
              Arrays.stream(beanNamesForType).forEach(System.out::println); 
          });
      }
  </code></pre>
  <p>Getting <code>UnsatisfiedDependencyException</code> for the above one.</p>
  <pre><code>Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'applicationReadyEventListener': Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [java.lang.Class] to required type [com.priti.com.common.config.CustomLogger]: Failed to convert value of type 'java.lang.Class' to required type 'com.priti.com.common.config.CustomLogger'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.Class' to required type 'com.priti.com.common.config.CustomLogger': no matching editors or conversion strategy found
  
  </code></pre>
  <p>Any lead on this would be helpful.</p>