@DataProvider (name=getData)
public static Object[][] getData(){
Excelreader excel = new Excelreader("C:\\WorkspaceExcel\\Datasource.xlsx"); private static
String sheetName="SmokeTest"; // Test Data stored in a a table with
columns and rows. Ex. UserNmae and password are the columns and data
for them in rows private static String tableName="CreatePolicy";
// Some logic to read the data table store the data in a 2
dimentional array.
// Some logic by which I store the columns as Keys and data for them
as values in a HASHTABLE Return the hashtable
}
@Test (dataProvider="getData")
public void testData(Hashtable<String, String> data){
/* Logic to read an .xlsx file which has Snenario name, TestCase Name and its corespnding runflag. If the runflag is true i need to read the scenario name and testcase name from the .xlsx file. */
/* I need some logic to pass the ScenarioName (equivalent to Sheetname in DP) and TestCase Name (equivalent to datatable name in DP) which i am getting by reading the excelfile to DataProvider, so i can get the data which i need to execute the test case */
/*I am doing the above as part of Hybridframework, where i have Scenario, TC, Test step details in one excel sheet and data for each testcase in one more sheet */
}
我的问题:我想要一些逻辑,所以在执行@Test 时,我应该动态传递数据文件路径、SheetName、TableName,因此可以使用相同的数据提供程序,这将为我提供不同的数据集来处理。
注意:数据提供者将以哈希表的形式返回在 excel 中以表格格式指定的数据,并带有表名。因此,如果将工作表路径、工作表名称和表名传递给数据提供者,那么我的 DP 将读取该表并以哈希表的形式返回整个数据表。