0

I have a scenario in which i need to run a login test case with 50 different users. I have created XML suite in order to generate dynamic XML file and using that to run the test cases. Could any one please help me on what i need to include in my suite to run the login case with different users.??

Gopi
  • 21
  • 1

1 Answers1

0

The suite.xml file only tells TestNG what to run: test classes, test methods, what to exclude, what to include, provided parameters, etc. You need to implement the tests and the way to supply them with data yourself. One of such useful constructs in TestNG are DataProvider:

// This method will provide data to any test method that declares that its Data Provider
// is named "loginData"
@DataProvider(name = "loginData")
public Object[][] createLoginData() {
 return new Object[][] {
   { "user1", "some other parameter" },
   { "user2", "more data"},
 };
}
 
//This test method declares that its data should be supplied by the Data Provider
//named "loginData"
@Test(dataProvider = "loginData")
public void testLogin(String userName, String data) {
   assert(verify(userName), data, "Received unexpected data for user: " + userName);
}

Code sample is paraphrased from DataProvides page on TestNG.org website

artdanil
  • 4,952
  • 2
  • 32
  • 49
  • Hi, Have used Data providers and it got worked. Thank you so much for your responses. – Gopi Jun 30 '21 at 07:02