Test Data Iteration at a test suite level

I have created two test cases: 1 for login and 1 for logout. Login test case is test data driven; for that i have created two variable: username and password.
I added both login and logout in a test suite and used data binding for login test case.
When i run the test case with one set of username and password then execution happens fine but when i have multiple sets of login credentials, say 2 then the execution happens as:

  1. Login Test case (with 1st set of data)
  2. Login Test case (with 2nd set of data)
  3. Logout
    I want to have operations as reusable methods and then use them in test suite as per flow. So if i want to login, logout for one set of user and then move on to next set of user, what should be the best approach in here.
    Please refer screenshot of the test suite for the configs.

The current solution is create a new test case, for example
Login Test Case
Logout Test Case
New Test Case 1:

  • Call Login tc
  • Do something
  • Call Logout tc
    New Test Case 2:
  • Call Login tc
  • Do something else
  • Call Logout tc

Then you can use these 2 new test cases in the test suite for data-driven approach.

You can write your login method something like this:

package myMethods

public class myClass {

  public static void login(String username, String password){
   	WebUI.setText(findTestObject('username-input'), username)
	WebUI.setText(findTestObject('password-input'), password)

And then call it in your test cases:

import myPackage

1 Like