October 12, 2018 – Make Selenium Easy
Hello Guys, DataProvider method in TestNG is a way to provide test data to Test annotated methods in a TestNG class. A typical DataProvider method looks like as below:
// A data provider method with return type as 2D array @DataProvider(name = “DataContainer”) public Object[] myDataProvider() { return new Object[][] { { “Mukesh”, “Otwani”, “[email protected]” }, { “Amod”, “Mahajan”, “[email protected]” }, { “Animesh”, “Prashant”, “[email protected]” }, { “Ankur”, “Singh”, “[email protected]” }, { “Amritansh”, “Kumar”, “[email protected]” } }; }
// A data provider method with return type as 2D array @DataProvider(name = “DataContainer”) public Object[] myDataProvider() { { “Mukesh”, “Otwani”, “[email protected]” }, { “Amod”, “Mahajan”, “[email protected]” }, { “Animesh”, “Prashant”, “[email protected]” }, { “Ankur”, “Singh”, “[email protected]” }, { “Amritansh”, “Kumar”, “[email protected]” } |
You can see that return type of above DataProvider method is an Object array. Is it mandatory to have return type as Object only? Answer […]