0

Consider i am having the data provider and test method as below

@DataProvider(name="Login1")
public Object[][] passData() throws IOException
{
    ExcelDataConfig config=new ExcelDataConfig(readPropertiesUtility.getFilePath(LoginConstant.excelPath));
    int rows=config.getRowCount(0);

    Object[][] data=new Object[rows-1][5];  

    for(int i=0;i<rows-1;i++)
    {
        data[i][0]=config.getData(0, i+1, 0));
        data[i][1]=config.getData(0, i+1, 1);
        data[i][2]=config.getData(0, i+1, 2);
    }
    return data;    
}


@Test(dataProvider="Login1")
public void logintoApplication(LoginFilterDetails loginFilterDetails) throws InterruptedException, IOException
{
    --etc
    ---  etc 
}

Here, Data Provider is returning 3 arguments and if i give 3 separate arguments in the test method, then it is working fine. But i need to pass it as single argument.

So, I have created one Class and pass it as arguments in method.But error is throwing as **"**org.testng.TestNGException: The data provider is trying to pass 3 parameters but the method TestNG.Login#logintoApplication takes 1"****

In some of my case, data provider will return some n number values .so, I need to handle with single argument in Test Method

Kindly suggest to solve this problem.

Subburaj
  • 2,294
  • 3
  • 20
  • 37

1 Answers1

1

You need to put in your 3 arguments as properties in the LoginFilterDetails object. In the array you should be having something as

for(int i=0;i<rows-1;i++){
 data[i][0]=new LoginFilterDetails(config.getData(0, i+1, 0) );//or whatever is returning 3 args
}
niharika_neo
  • 8,441
  • 1
  • 19
  • 31