package com.testng.examples; import org.testng.annotations.Test; import org.testng.annotations.DataProvider; public class DataProviderDemo { @Test(dataProvider = "dp") public void dataProviderDemo(Integer id, String firstName,String lastName) { System.out.println(id + " " + firstName + " " + lastName); } @DataProvider(name="testData1") public Object[][] td1() { Object[][] data = new Object[4][3]; data[0][0] = 10; data[0][1] = "Ram"; data[0][2] = "Kumar"; data[1][0] = 20; data[1][1] = "Shyam"; data[1][2] = "Sundar"; data[2][0] = 30; data[2][1] = "Krishna"; data[2][2] = "Nandan"; data[3][0] = 40; data[3][1] = "Geeta"; data[3][2] = "Viswas"; return data; } @DataProvider(name="testData2") public Object[][] td2() { Object[][] data = {{10, "Ram", "Kumar"}, {20, "Shyam", "Sundar"}, {30, "Krishna", "Kumar"}, {40, "Sangeeta","Devi"} }; return data; } @DataProvider public Object[][] dp() { return new Object[][] { new Object[] { 1, "a","c" }, new Object[] { 2, "b", "d"}, }; } }
TestNG DataProvider Example
Subscribe to:
Posts (Atom)
ReplyDeleteAmazing, thanks a lot my friend, I was also siting like a your banner image when I was thrown into Selenium.
When I started learning then I understood it has got really cool stuff. Best Selenium Training Institute in Chennai |
Selenium Training in Velachery