Oct 12
TestNG Tutorials 53: DataProvider in TestNG – Is It Mandatory To Have Return Type as Object in DataProvider Method
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
// A data provider method with return type as 2D array
@DataProvider(name = "DataContainer")
public Object[] myDataProvider() {
return new Object[][] {
{ "Mukesh", "Otwani", "Motwani@gmail.com" },
{ "Amod", "Mahajan", "Amahajan@hotmail.com" },
{ "Animesh", "Prashant", "aprashant@gmail.com" },
{ "Ankur", "Singh", "asingh@gmail.com" },
{ "Amritansh", "Kumar", "akumar@gmail.com" }
};
}
|
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 […]