How to programmaticly set spring autowired properties without using setter and Spring config?
I have a interface
and implementing classCode:public interface MyService { .. }
In unit test I would like to mock MyDao and set that to MyServiceImpl without making setter method to MyServiceImpl.Code:public class MyServiceImpl implements MyService { .. @Autowiring private MyDao myDao; .. }
How to do it?Code:public class MyServiceTest { .. @Test public void doTest() { MyService myService = new MyServiceImpl(); MyDao myDaoMock = Mockito.mock(MyDao.class); .. // How to wire myDaoMock to myService without making setMyDao(..) method for MyServiceImpl } .. }


Reply With Quote
