How to create a test suite inorder to run a single test cases with 50 different users

66 Views Asked by At

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.??

1

There are 1 best solutions below

1
artdanil On

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