@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 を実行するときに、データのファイル パス、シート名、テーブル名を動的に渡す必要があります。これにより、同じデータ プロバイダーを使用でき、作業するデータの異なるセットが得られます。
注: データ プロバイダーは、Excel で指定されたデータのハッシュ テーブルの形式で、テーブル名を含む表形式で返します。したがって、ワークシート パス、シート名、およびテーブル名がデータ プロバイダーに渡されると、DP はそのテーブルを読み取り、データ テーブル全体をハッシュ テーブルの形式で返します。