Spring 整合 JUnit

Posted by Bruce Tsai

依賴元件

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>${spring.version}</version>
</dependency>

配置 Runner

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring/applicationContext.xml")
public class TestMyService {

    @Autowired
    ApplicationContext context;

    @Test
    public void testCall(){
        ...
    }

}

results matching ""

    No results matching ""