springmvc4+Junit單元測試的幾個重要點

/**
 * Created by dell on 2017/10/11.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration//必須
@ContextConfiguration(locations = {"classpath:/spring-mvc.xml", "classpath:/spring-config.xml"})
public class TestService {

    @Resource
    private CommonViewService commonViewService;

    @Test
    public void test1() {
        List<EntityVAgeGroup> list = commonViewService.getAgeGroup();
        System.out.println(list.toString());
    }

}


//spring4和一些早期的serverlet-api集成有bug
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>test</scope>
</dependency>



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章