Mockito configures a mock object in the Spring container

Mockito configures a mock object in the Spring container

    

    In unit tests, resolve some bean dependencies when initializing the Spring container

    

    <bean name="testBeanId" class="com.company.testedClass">
        <property name="yourService" ref="yourBeanId"/>
    </bean>
    
    <!--The object referenced by the mock -->
    <bean name="yourBeanId" class="org.mockito.Mockito" factory-method="mock">
        <constructor-arg value="com.your.class.path.yourClass"/>
    </bean>

 

    

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326353320&siteId=291194637
Recommended