testng-dataproviders icon indicating copy to clipboard operation
testng-dataproviders copied to clipboard

Generate a single report for multiple rows read from CSV in TestNG- Data Provider

Open sudhanshuprakash opened this issue 4 years ago • 6 comments

@sergueik I am using TestNG-DataProvider to generate multiple reports for a test case which is running in loop. The data is fetched from CSV sheet. Now the issue is, I have a column named count which contains value 1,2 3.. and so on. The values are in multiple rows. Suppose the value 1 present in column count is in 5 rows, value 2 is in 7 rows and so on. I want to generate a TestNG report for the column containing 1 as one report, column containing 2 as another report and so on. The number of different values in count column should be equal to the TestNG reports generated. I am able to generate report for each of the line but not for 5 rows as one. I am attaching the code I have written till now. The CSV looks like this: enter image description here

And the code I have written till now is below:

@DataProvider(name = "userDetails") public static Object[][] readCsv() throws IOException { CSVReader csvReader = new CSVReader(new FileReader("C:\Users\admin\Desktop\Appium3.csv"),','); List<String[]> csvData=csvReader.readAll(); Object[][] csvDataObject=new Object[csvData.size()][2]; for (int i=0;i<csvData.size();i++) { csvDataObject[i]=csvData.get(i); } return csvDataObject; }

@Test(dataProvider = "userDetails",priority = 2) public void userLoginTest(String PLATFORM_NAME,String PLATFORM_VERSION,String DEVICE_NAME,String UDID,String SUPPORT_LOCATION_CONTEXT,String NO_RESET, String FULL_RESET, String appPackage,String appActivity, String url,String Count, String Action, String Element, String Identifier, String XPath , String ClassName , String SendKeysWait , String MoveToX, String MoveToY, String MoveToXPathClassName, String DownToX, String DownToY) throws InterruptedException {

if (Action.contains("Click") && Element.contains("Button")&&Identifier.contains("XPath")) {
    Button b1 = new Button();
    b1.ButtonClickByXpath(GetAppiumDriver.driver, XPath);

}

}

sudhanshuprakash avatar Jun 01 '20 10:06 sudhanshuprakash