Eclipse TestNG

来源:互联网 发布:mac无苹果安装win7系统 编辑:程序博客网 时间:2024/06/09 18:52

1.安装TestNG 插件

  在Eclipse Marketplace里安装插件,目前最新插件是6.9版本,要求的JDK是1.7,,否则会不能执行。

这里指定JDK,



2.编写测试代码:

  此项目基于Spring 的maven工程:

 

@ContextConfiguration(locations = { "classpath*:config/spring/spring-aop.xml",        "classpath*:config/spring/spring-web.xml",         "classpath*:config/spring/spring-dal.xml",        "classpath*:spring-datasource-test.xml",        "classpath*:config/spring/spring-init.xml",        "classpath*:config/spring/spring-tsp-framework.xml",        "classpath*:config/spring/spring-cache.xml",        "classpath:config/spring/spring-tsp.xml",        "classpath*:config/spring/spring-jms.xml",         "classpath*:config/spring/spring-log.xml"              })@Testpublic class BaseTest extends AbstractTestNGSpringContextTests {}
上面的@ContextConfiguration用来配置数据源等信息

此时可以编写测试类:

public class IDiyServiceTest extends  BaseTest {@Resource( name = "diyServiceImpl" )private IDiyService iDiyService;  @Test  public void testGetDiyInfoByProductId() {  ProductDetailRequestVo productDetailRequestVo=new ProductDetailRequestVo();  productDetailRequestVo.setProductType(2);  productDetailRequestVo.setProductId(5004635);  productDetailRequestVo.setRequestSourceCode(2);  ResponseVo resp=iDiyService.getDiyInfoByProductId(productDetailRequestVo);  Assert.notNull(resp.getData());      }


0 0
原创粉丝点击