springmvc4+Junit单元测试的几个重要点

来源:互联网 发布:平板电脑win10系统优化 编辑:程序博客网 时间:2024/05/29 13:47
/** * 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>