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>



猜你喜欢

转载自blog.csdn.net/xiaonannew/article/details/78206597