title: How to use Kotlin beans dsl initializer in SpringBootTest
body: <p>I have a simple application with several beans declared with kotlin beans dsl:</p>
  
  <pre><code>@SpringBootApplication
  class App
  
  val beans = beans {
      bean&lt;A&gt;()
  }
  
  fun main(args: Array&lt;String&gt;) {
      runApplication&lt;MatchmakerApp&gt;(*args) {
          addInitializers(beans)
      }
  }
  
  @RestController
  class AppController(val a: A) {
      // some code
  }
  
  class A
  </code></pre>
  
  <p>and I have an integration test:</p>
  
  <pre><code>@RunWith(SpringRunner::class)
  @SpringBootTest
  class AppControllerTest {
      @Test
      fun dummyTest() {
          assert(true)
      }
  }
  </code></pre>
  
  <p>Launching this test I'm getting </p>
  
  <pre><code>UnsatisfiedDependencyException: Error creating bean with name appController 
  Caused by: NoSuchBeanDefinitionException: No qualifying bean of type 'A' available:`
  </code></pre>
  
  <p>It seems beans initializer was not invoked during <code>SpringBootTest</code> context creation.</p>
  
  <p>What do we need to add kotlin bean dsl initializer in SpringBootTest?</p>
  
  <p>The general way with <code>@ContextConfiguration(initializers = ...)</code> does not work here, because it looks for classes.</p>