Prasanta Biswas:
I have a testng test method and a data provider for it. I want to make the test case reusable for Multiple Clients that have this feature to be tested. The only catch is that the feature works differently on different clients that is I have to provide different number of inputs to the same feature for different clients and the end result is same for all.
Currently I am doing this by defining multiple test methods with data providers for multiple clients that have this feature.
Example:-
@DataProvider(name="dp1")
public Object[][] getDataForClient1()
{
//return data
}
@Test(dataProvider="dp1", groups={"client1"})
public void transferCredit(String senderId,String receiverId,String amount,String expectedResult)
{
//Perform operation
}
@DataProvider(name="dp2")
public Object[][] getDataForClient2()
{
//return data
}
@Test(dataProvider="dp2", groups={"client2"})
public void transferCredit(String senderId,String receiverId,String amount,String paymentReference,String expectedResult)
{
//Perform operation
}
I have developed a common test logic to handle different sets of parameters. What I am not able to do is the reuse the same test method for different sets of parameters.
I want to do it like the following
@DataProvider(name="dp")
public Object[][] getData()
{
//return data
}
@Test(dataProvider="dp", groups={"client1,client2"})
public void transferCredit(String ... params)
{
//Perform operation
}
But doing this gives testng exception that is the parameters are not matching. So is there any way to do this in TestNG?
Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE