title: How to inject multiple mocks of the same interface
body: <p>The Java class (called <code>ServiceCaller</code>) I wish to test has this:</p>
  
  <pre><code>@Autowired @Qualifier(value="serviceA")
  SomeService serviceA;
  
  @Autowired @Qualifier(value="serviceB")
  SomeService serviceB;
  </code></pre>
  
  <p>(there's a <code>doWork()</code> method that will check a condition and call either A or B).</p>
  
  <p>How do I inject a mock of each service into the appropriate variable?</p>
  
  <p>My <a href="http://junit.org/" rel="noreferrer">Junit</a> has this:</p>
  
  <pre><code>@InjectMocks ServiceCaller classUnderTest = new ServiceCaller();
  
  @Mock SomeService mockServiceA;
  @Mock SomeService mockServiceB;
  </code></pre>
  
  <p>Yet when I run my tests to check that service A/B called under the correct condition, I get null pointers as the mock hasn't been injected.</p>
  
  <p>Obviously its because of multiple dependencies on the same interface (<code>SomeService</code>). Is there a way to specify the qualifier when declaring the mock service? Or do I need to have setters for the dependencies and set the old fashioned way?</p>