Null @Autowired beans in unit test case
<p>I am trying to auto-wire a spring managed bean to use in my unit test case. But autowired bean is always null. Below are my setting.</p>

<blockquote>
  <p>my unit test class</p>
</blockquote>

<pre><code>@RunWith(MockitoJUnitRunner.class)
@ContextConfiguration(locations = "classpath*:business-context-test.xml")
public class SMSGatewayTest {

    @Autowired
    @Qualifier("mySMSImpl")
    private ISMSGateway smsGateway;

        @Test
        public void testSendTextMessage() throws Exception {
          smsGateway.sendText(new TextMessage("TEST")); 
          //  ^___________ this is null, even though I have set ContextConfiguration 
        }

}
</code></pre>

<blockquote>
  <p>spring managed bean</p>
</blockquote>

<pre><code>package com.myproject.business;

@Component("mySMSImpl")
public class MySMSImpl implements ISMSGateway {

    @Override
    public Boolean sendText(TextMessage textMessage ) throws VtsException {
          //do something
    }

}
</code></pre>

<blockquote>
  <p>context for unit test case</p>
</blockquote>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"&gt;


       &lt;context:annotation-config/&gt;
       &lt;context:component-scan base-package="com.myproject.business"/&gt;
&lt;/beans&gt;
</code></pre>

<p>I have seen many questions and all are giving the answers that I've already incorporated in my code. Can some one tell me what I am missing. I am using intellij 14 to run my test case.</p>