首页 > 编程语言 > 详细

maven springTest结合junit单元测试

时间:2019-02-22 11:04:37      阅读:203      评论:0      收藏:0      [点我收藏+]

1.引入相关依赖

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

2.新建java单元测试文件加上spring配置文件的注解 

@RunWith(SpringJUnit4ClassRunner.class)  
@ContextConfiguration({"classpath*:spring/*.xml"})
public class MapperTest {

    @Autowired
    private ProductTypeMapper mapper;
    
    @Test
    public void testProductType(){
        ProductTypeExample example = new ProductTypeExample();
        List<ProductType> list = mapper.selectByExample(example);
        System.out.println(list);
    }
}

 

maven springTest结合junit单元测试

原文:https://www.cnblogs.com/czsblog/p/10416756.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!