Using dataprovider in TestNG

package com.automation;

import …;

 

@Listeners({com.automation.listenner.Local.class})

public class testClass{

AppiumDriver driver = null;

@BeforeMethod
public void beforeMethod() {

}

@DataProvider
public Object[][] inputDatas() {
Object[][] inputDatas = null;
String csvFile = “C:” + File.separator + “file.csv”;
try {
List<String> lines = Files.readAllLines(new File(csvFile).toPath());
inputDatas = new Object[lines.size()][10];
String[] datas = new String[10];
String line = “”;
for (int i = 0; i < lines.size(); i++) {
line = lines.get(i);
datas = line.split(“,”);
inputDatas[i] = datas;
}
} catch (Exception e) {
e.printStackTrace();
}

return inputDatas;
}

@Test(dataProvider = “inputDatas”)
public void testFunction(String a, String b, String c, String d, String e, String f, String g, String h, String i, String j) {

}

@AfterMethod
public void afterMethod() {

}

}

Leave a Reply

Your email address will not be published. Required fields are marked *