mardi 6 octobre 2015

How to create "deep" mock of a spring bean?

I have a spring beans like this

@Component
public class Service extends AbstractService {
        @Autowired
        private OtherService otherService;
}

For test I created a test context with Service mock

<bean id="serviceMock" class="org.easymock.EasyMock" factory-method="createMock"  primary="true">
    <constructor-arg index="0" type="java.lang.Class" value="com.pkg.my.Service"/>
</bean>

The mock still requires me to mock all the autowired dependencies. Is there a way to create just "dumb" mock without the need to create beans for all the dependencies?

Aucun commentaire:

Enregistrer un commentaire