I would like to inject a Mockito mock object into a Spring (3+) bean for the purposes of unit testing. My bean dependencies are currently injected by using the @Autowired annotation on private member fields.
Howto do it simple with XML configuration:
<bean id="dao" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="com.package.Dao" />
</bean>
It's pretty elegant.
Žádné komentáře:
Okomentovat