This is my Provider method
@DataProvider(name = "loginDataSet")
public static Object[][] loginSet() {
return new Object[][]{
{
String.valueOf(LoginProvider.builder()
.username(data.getUsername())
.password(data.getPassword())
.build())
}
};
}
This is my Test Method
@Test(dataProvider = "loginDataSet", dataProviderClass = LoginData.class)
public void loginAxis(String userValue, String userPassword) {
new UserLogin(userValue,userPassword);
}
Getting following exception
org.testng.internal.reflect.MethodMatcherException:
[public void Login.AxisLogin.loginAxis(java.lang.String,java.lang.String)] has no parameters defined but was found to be using a data provider (either explicitly specified or inherited from class level annotation).
Data provider mismatch
Method: loginAxis([java.lang.String arg0, java.lang.String arg1])
Arguments: [(java.lang.String) LoginProvider(username=863331712, password=Test@123)]
Please help me with the solution
I tried calling Data using Lombok builder for Selenium Data Provider getting method mismatch error.
It is not a Lombok issue.
See what the error says:
Data provider mismatch
Method: loginAxis([java.lang.String arg0, java.lang.String arg1])
Arguments: [(java.lang.String) LoginProvider(username=863331712, password=Test@123)]
So your loginAxis expects 2 strings: userValue and userPassword
But your loginDataSet DataProvider returns an array with the string representation of your LoginProvider instance.
As a result, the test expected 2 strings but received only one.
So you either have to change the data provider (whatever the 'data' object means in your case):
@DataProvider(name = "loginDataSet")
public static Object[][] loginSet() {
return new Object[][]{
{
data.getUsername(),
data.getPassword()
}
};
}
Or you need to change the Test parameter to LoginProvider (and remove String.valueOf() from the data provider of course):
@Test(dataProvider = "loginDataSet", dataProviderClass = LoginData.class)
public void loginAxis(LoginProvider loginProvider) {
new UserLogin(loginProvider.getUsername(), loginProvider.getPassword());
}