private Iterator<Object[]> parseCsvData(String fileName) throws IOException
{
BufferedReader input = null;
File file = new File(fileName);
input = new BufferedReader(new FileReader(file));
String line = null;
ArrayList<Object[]> data = new ArrayList<Object[]>();
while ((line = input.readLine()) != null)
{
String in = line.trim();
String[] temp = in.split(“,”);
List<Object> arrray = new ArrayList<Object>();
for(String s : temp)
{
arrray.add(Integer.parseInt(s));
}
data.add(arrray.toArray());
}
input.close();
return data.iterator();
}
/**
Use the above method in dataprovider
**/
@DataProvider(name = "testData")
public Iterator<Object[]> testData() throws IOException
{
return parseTestData(<Location of csv file>);
}
@Test(dataProvider = “testData”)
public void verifyLoginUsingCsv (String username, String password, String testDescription)
{
/** Your Test Code **/
}
Friday, February 12, 2021
CSV dataset to DataProvider
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment