testng入门教程14数据驱动(不同文件)
2016-12-20 22:24
435 查看
数据与test脚本不在同一文件时,下面是数据:
下面是test脚本:
右键----->RunAs----->TestNG test 运行结果如下:
package data_driver_two_parts; import org.testng.annotations.DataProvider; public class TestDataProvider { @DataProvider public static Object[][] DataMethodNoName(){ return new Object[][]{ {"data with no name 1"}, {"data with no name 2"}, {"data with no name 3"} }; } @DataProvider(name="datamethodwithname") public static Object[][] DataMethodwithName(){ return new Object[][]{ {"data with name 4"}, {"data with name 5"}, {"data with name 6"} }; } }
下面是test脚本:
package data_driver_two_parts; import org.testng.annotations.Test; public class testcase_for_driver { @Test(dataProvider="DataMethodNoName",dataProviderClass=data_driver_two_parts.TestDataProvider.class) public void testDataDriven_1(String a){ System.out.println("this is : "+a); } @Test(dataProvider="datamethodwithname",dataProviderClass=data_driver_two_parts.TestDataProvider.class) public void testDataDriven_2(String b){ System.out.println("l am "+b); } }
右键----->RunAs----->TestNG test 运行结果如下:
[TestNG] Running: C:\Users\chenjia\AppData\Local\Temp\testng-eclipse--112979388\testng-customsuite.xml this is : data with no name 1 this is : data with no name 2 this is : data with no name 3 l am data with name 4 l am data with name 5 l am data with name 6 PASSED: testDataDriven_1("data with no name 1") PASSED: testDataDriven_1("data with no name 2") PASSED: testDataDriven_1("data with no name 3") PASSED: testDataDriven_2("data with name 4") PASSED: testDataDriven_2("data with name 5") PASSED: testDataDriven_2("data with name 6") =============================================== Default test Tests run: 6, Failures: 0, Skips: 0 =============================================== =============================================== Default suite Total tests run: 6, Failures: 0, Skips: 0 ===============================================
相关文章推荐
- testng入门教程13同文件数据驱动
- testng入门教程15数据驱动
- testng入门教程16数据驱动(把数据写在xml)
- 数据驱动测试三:使用TestNG、Apache POI和Excel文件进行数据驱动
- seleniumWebDriver自动化测试框架_02TestNG和txt文件进行数据驱动
- 使用TestNG 和 CSV文件进行数据驱动
- 关键字驱动框架入门教程-12-数据驱动技术
- Node初学者入门,一本全面的NodeJS教程,微小的web框架,能实现文件上传功能以及数据解析功能
- 关键字驱动框架入门教程-4-搭建数据引擎-用Apache POI去读取数据
- UI自动化测试系列之TestNg-TestNg数据驱动二------>以XML外部文件作为数据驱动(1)
- TestNG入门教程-14-失败重跑的第二种方法
- TestNG入门教程-3-Testng.xml文件介绍
- 数据驱动测试二:使用TestNG和CSV文件进行数据驱动
- lingo入门教程之三 --- 文件数据处理
- Python学习入门基础教程(learning Python)--5.7 Python文件数据记录存储与处理
- Scott Mitchell 的ASP.NET 2.0数据教程之54:上传文件
- [转载][教程]vs2005入门 之 文件上传控件(FileUpLoad)[视频]
- Windows文件系统过滤驱动开发教程
- ASP小偷(远程数据获取)程序入门教程
- Scott Mitchell 的ASP.NET 2.0数据教程之56:添加新记录时包含一个文件上传选项