title: Spring Boot autowire configuration class into Junit Test
body: <p>I currently run into a problem with Junit testing in Spring Boot. I have an <code>@Configuration</code> class for which I want to test the <code>@Bean</code> methods. Because these methods are skipped during tests, I extracted the content of the configuration method to a protected method which will then be called inside the <code>@Bean</code> method of the <code>@Configuration</code> class.
  I did that so I can test the behaviour of the methods. Inside this method different <code>@ConfigurationProperties</code> are used to load some setups.</p>
  <p>Now, in my <code>ConfigurationTest</code> class, I am mocking the <code>ConfigurationProperties</code> classes so I can test the correct behaviour of the <code>@Bean</code> method.</p>
  <p>My problem is, that my Mockito mocks of the <code>ConfigurationProperties</code> classes always return null, when I am inside the <code>@Bean</code> method (more specifically inside the protected method that is called from the @Bean method). It feels like there is a problem with how I setup the <code>@Configuration</code> class. Currently I am autowiring it.</p>
  <p>My question now is, how do I setup the <code>@Configuration</code> class correctly, so I can call its functions and mock the return values of the there used <code>@ConfigurationProperties</code> classes?</p>
  <p>Thanks in advance!</p>