title: Injecting a String property with @InjectMocks
body: <p>I have a Spring MVC <code>@Controller</code> with this constructor:</p>
  
  <pre><code>@Autowired
  public AbcController(XyzService xyzService, @Value("${my.property}") String myProperty) {/*...*/}
  </code></pre>
  
  <p>I want to write a standalone unit test for this Controller:</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class AbcControllerTest {
  
      @Mock
      private XyzService mockXyzService;
  
      private String myProperty = "my property value";
  
      @InjectMocks
      private AbcController controllerUnderTest;
  
      /* tests */
  }
  </code></pre>
  
  <p>Is there any way to get <code>@InjectMocks</code> to inject my String property? I know I can't mock a String since it's immutable, but can I just inject a normal String here?</p>
  
  <p><code>@InjectMocks</code> injects a null by default in this case. <code>@Mock</code> understandably throws an exception if I put it on <code>myProperty</code>. Is there another annotation I've missed that just means "inject this exact object rather than a Mock of it"?</p>