title: How to unit test an Spring @Bean CommandLineRunner?
body: <p>I'm using Spring Boot in a little PoC, and I'm trying to test a @Bean implementation. I have this code:</p>
  
  <pre><code>@SpringBootApplication
  public class Application {
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
      @Bean
      CommandLineRunner init(@Value("${db.resetAndLoadOnStartup:true}") boolean resetAndLoadOnStartup,
                             SequenceIdRepository sequenceRepository,
                             UserAccountRepository userAccountRepository,
                             BookRepository bookRepository) {
          return args -&gt; {
              log.info("Init Application...");
              if (resetAndLoadOnStartup) {
                  fillDBData(sequenceRepository, userAccountRepository, bookRepository);
              }
              log.info("Aplication initiated!");
          };
      }
  
      private void fillDBData(SequenceIdRepository sequenceRepository,
                              UserAccountRepository userAccountRepository,
                              BookRepository bookRepository) {
          // Some code...
      }
  ...
  }
  </code></pre>
  
  <p>How can I unit test this @Bean commandLineRunner? Yeah, maybe I could unit test the 'fillDBData' method (putting protected or with powermock), but I would like to learn if there's a way to test the Spring @Bean "completely".</p>