@Import vs @ContextConfiguration for importing beans in unit tests : <p>I was able to set up and successfully run three different test configurations with SpringBoot 1.5.3</p>

<p>Method #1. Importing Bean with use of <code>@Import</code> annotation</p>

<pre><code>@RunWith(SpringJUnit4ClassRunner.class)
@Import({MyBean.class})
public class MyBeanTest() {
    @Autowired
    private MyBean myBean;
}
</code></pre>

<p>Method #2. Importing Bean with use of <code>@ContextConfiguration</code> annotation</p>

<pre><code>@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {MyBean.class})
public class MyBeanTest() {
    @Autowired
    private MyBean myBean;
}
</code></pre>

<p>Method #3 (with internal class configuration; based on <a href="https://spring.io/blog/2011/06/21/spring-3-1-m2-testing-with-configuration-classes-and-profiles" rel="noreferrer">the official blog post</a>)</p>

<pre><code>@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader=AnnotationConfigContextLoader.class)
public class MyBeanTest() {

    @Configuration
    static class ContextConfiguration {
        @Bean
        public MyBean myBean() {
            return new MyBean();
        }
    }

    @Autowired
    private MyBean myBean;

}
</code></pre>

<p>Taking into account <code>@Import</code> annotation documentation </p>

<blockquote>
  <p>Indicates one or more {@link Configuration @Configuration} classes to
  import.</p>
</blockquote>

<p>and the fact that <code>MyBean</code> is not a configuration class, but a bean class annotated with <code>@Component</code> annotation it looks like Method #1 is not correct.</p>

<p>From <code>@ContextConfiguration</code> documentation</p>

<blockquote>
  <p>{@code @ContextConfiguration} defines class-level metadata that is
  used to determine how to load and configure an {@link
  org.springframework.context.ApplicationContext ApplicationContext}
  for integration tests.</p>
</blockquote>

<p>Sounds like it is better applicable to unit tests, but still, should load a kind of a configuration.</p>

<p>Methods #1 and #2 are shorter and simpler.
Method #3 looks like a correct way. </p>

<p>Am I right? Are there other criteria why I should use method #3, like performance or something else?</p>
