Step1: Created a class A with two methods:
@Test(dataProvider="testdata")
InputToForm()
@DataProvider(name="testdata")
readDataFromExcel()
Step2: Created a class B, where I need to call the method InputToForm() with the data.
Step1: Created a class A with two methods:
@Test(dataProvider="testdata")
InputToForm()
@DataProvider(name="testdata")
readDataFromExcel()
Step2: Created a class B, where I need to call the method InputToForm() with the data.
Please read about inheritance and more about core java in general before you jump into automation, else you will be stuck at every small issue.
You can resolve your issue by simply using inheritance, as mentioned below.
Your data provider in a different class
public class DataLibrary {
@DataProvider(name="loginData")
public Object[][] loginData(){
return new Object[][]{
{"username", "password"}
};
}
}
And here goes your login class.
public class Login extends DataLibrary {
@Test(dataProvider = "loginData")
public void login(String username, String password){
System.out.println("username="+username+" password="+password);
}
}