Spring,
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:test-context.xml")
Spring bean, , beans, , , (, BottleCounter),
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="myBottleCounter" name="myBottleCounter" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.world.hello.BottleCounter"/>
</bean>
<bean id="myRoom" class="org.world.hello.Room">
<property name="bottleCounter" ref="myBottleCounter"></property>
<property name = "numBottles" value = "10"></property>
</bean>
</beans>
, , , beans, Spring path , xml. beans context:exclude-filter, -
<bean id="myBottleCounter" name="myBottleCounter" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.world.hello.BottleCounter"/>
</bean>
<context:component-scan base-package="org.world.hello">
<context:exclude-filter type="regex" expression="org\.world\.hello\.Bottle*"/>
</context:component-scan>
, . , , Spring xml Spring . , , , Spring.
, , - . , , unit test ( beans), . , unit test , , , , . Spring , , @Koitoer , , beans, ,
In practice, people are usually not bothered by the difference. Spring refers to its test as unit tests. The general case is what @Nenad Bozic calls a hybrid convention where you would like to bite off just a few objects, for example. connecting to a database or the like, and based on some of your comments, this is what you need.