How do I mock an autowired @Value field in Spring with Mockito?

I’m using Spring 3.1.4.RELEASE and Mockito 1.9.5. In my Spring class I have: @Value(“#{myProps[‘default.url’]}”) private String defaultUrl; @Value(“#{myProps[‘default.password’]}”) private String defaultrPassword; // … From my JUnit test, which I currently have set up like so: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ “classpath:test-context.xml” }) public class MyTest { I would like to mock a value for my “defaultUrl” field. Note … Read more