I don't find any approach for my usecase. Let's say that a testcase needs to be executed with 2 roles, and for each role there should be 2 test run with different data.
@Test (dataProviderClass = roles.class, dataProvider = roles.SUPERADMIN_ADMIN)
@Parameters({"data1", "data2"})
public void myTestCase () {
...
}
SUPERADMIN and DATA1, SUPERADMIN and DATA2, ADMIN and DATA1, ADMIN and DATA2
But this is not working since parameters should be set in xml file and multiple dataProviders are not supported.
Any high level help would be appreciated about how to approach this problem.
TestNG does not let you tie a single test method to multiple data providers.
That being said, here's a sample that shows how to make your data provider dynamic enough such that it modifies itself based on the parameter passed from a suite file.
Here's the suite file that we are going to be working with
Here's the execution output: