【发布时间】:2017-08-28 17:40:12
【问题描述】:
**请帮助我,我想要一个场景,它将返回相应类名的所有测试方法(B 列),在这里我正在尝试创建一个函数,它将返回我特定的方法列表类 //我们可能会使用一些集合框架(因为我是 java 新手,不知道该怎么做)请看附图 **
@Test
public void excel() throws Exception{
ExcelUtils.setExcelFile("E:\\EclipseTests\\DemoTests\\src\\main\\java\\testdata\\testdata.xls", "Sheet1");
int ic=ExcelUtils.getRowUsed();
int row=utility.ExcelUtils.getRowContains("Class1", 0);
System.out.println("row num "+row);
List<String>value=method("Class1",ic);//need to get all the values of column B in the excel when
//i put class name/column 0 value in this function byietrating using loop
}
public static List<String>method(String classz ,int ic) throws Exception{
for(int i=1;i<ic;i++){
List<String>sMethod=new ArrayList<String>();
String sClassName=ExcelUtils.getCellData(i, 0);
String sClassName1=ExcelUtils.getCellData(i-1, 0);
if(sClassName1.equals(sClassName) ){
int row=utility.ExcelUtils.getRowContains(sClassName, 0);
//need to write some logic which will return me a list which will contains
//[Test1 ,Test2 ,Test3 ,Test4 ,Test5] for class1
sMethod.add("value from B column");// i.e Test1
sMethod.add("value from B column");// i.e Test2
sMethod.add("value from B column");// i.e Test3
sMethod.add("value from B column");// i.e Test4
sMethod.add("value from B column");// i.e Test5
}
}
return sMethod;
}
}
//similarly for class2 it should return [Test6,Test7,Test8,Test9,Test10]
//similarly for class3 it should return [Test6,Test11,Test12,Test13,Test14]
【问题讨论】:
标签: java excel selenium automation apache-poi