Generate a single report for multiple rows read from CSV in TestNG- Data Provider
sudhanshuprakash opened this issue · 2 comments
@hemanthsridhar 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);
}
}
Can you please help me on this @hemanthsridhar . I am stuck on this from a long time. And not able to find any answers anywhere. Can you let me know if it is even possible. Since, you have worked on TestNG-dataprovider.
@sudhanshuprakash hi Sudhan.
The issue is not related to this library.
Marking this as invalid.
However, related to your query please use the library I have built. It will solve your issue.
Please go through the below link
https://medium.com/@hemanthsridhar/testng-csv-excel-data-provider-52f163313fa9
For reporting I suggest allure reports.
https://docs.qameta.io/allure/