// This is from another file but same package.
public class EmpData
{
@DataProvider
public Object[][] getData()
{
Object[][] data= {{"Hello","text","1"},{"bye","Message","32"},{"solo","call","678"}};
return data;
}
}
// Type -1 ( This is from another file but the same package.)
public class DPClass extends EmpData
{
@Test(dataProvider="getData")
public void testCaseData(String Greeting, String Communication, String Id)
{
System.out.println(Greeting+Communication+Id);
}
}
// Type -2
public class DPClass
{
@Test(dataProvider="getData", dataProviderClass=DPClass.class)
public void testCaseData(String Greeting, String Communication, String Id)
{
System.out.println(Greeting+Communication+Id);
}
}
In above there are two separate file DPClass.java
and EmpData.java
in one single package we can provide data to DPClass
in both way either add parameter in @Test annotation and by extending class with adding parameter in @Test
annotation. If we are achieving this by extending class then why TestNG provided DataProviderClass? Correct me if I wrong for this concept, I need difference for both.