Skip to main content
formatting
Source Link
Bharat Mane
  • 6.8k
  • 11
  • 41
  • 69

If the test methods are repeatedly used in other tests and can be made reusable you could define it as a separate method. For example Login method is used by almost all the test cases. Creating a separate login test method enhances re-usability and avoids writing code from scratch each time.

For testing login method the test method should be separate and re-usable as below:
testLogin()

<br>
testLogin()

If you are defining a specific scenario that is seldom re-usable you can group up the verification points in a single method. Alan's suggestion is valuable in this case. Define a package say payment for all payment related testcases. Define a class for each payment test case say testShoppingPay, testRecurringPay. Inside each class you need to call a reusable method for initial setup. Write a testmethod for verification points involved.

It would look like:
testinitSetup() //Method for initial test case setup

test() //contains all verification points
{
testLogin() //Calls reusable login method
Assert(Element1Present)
Assert(Element2Present)
......
......
}

<br>
testinitSetup() //Method for initial test case setup<br>

test() //contains all verification points<br>
{<br>
      testLogin() //Calls reusable login method<br>
      Assert(Element1Present)<br>
      Assert(Element2Present)<br>
......<br>
......<br>
}

If the test methods are repeatedly used in other tests and can be made reusable you could define it as a separate method. For example Login method is used by almost all the test cases. Creating a separate login test method enhances re-usability and avoids writing code from scratch each time.

For testing login method the test method should be separate and re-usable as below:
testLogin()

If you are defining a specific scenario that is seldom re-usable you can group up the verification points in a single method. Alan's suggestion is valuable in this case. Define a package say payment for all payment related testcases. Define a class for each payment test case say testShoppingPay, testRecurringPay. Inside each class you need to call a reusable method for initial setup. Write a testmethod for verification points involved.

It would look like:
testinitSetup() //Method for initial test case setup

test() //contains all verification points
{
testLogin() //Calls reusable login method
Assert(Element1Present)
Assert(Element2Present)
......
......
}

If the test methods are repeatedly used in other tests and can be made reusable you could define it as a separate method. For example Login method is used by almost all the test cases. Creating a separate login test method enhances re-usability and avoids writing code from scratch each time.

For testing login method the test method should be separate and re-usable as below:

<br>
testLogin()

If you are defining a specific scenario that is seldom re-usable you can group up the verification points in a single method. Alan's suggestion is valuable in this case. Define a package say payment for all payment related testcases. Define a class for each payment test case say testShoppingPay, testRecurringPay. Inside each class you need to call a reusable method for initial setup. Write a testmethod for verification points involved.

It would look like:

<br>
testinitSetup() //Method for initial test case setup<br>

test() //contains all verification points<br>
{<br>
      testLogin() //Calls reusable login method<br>
      Assert(Element1Present)<br>
      Assert(Element2Present)<br>
......<br>
......<br>
}
Source Link
Aruna
  • 1.1k
  • 1
  • 8
  • 15

If the test methods are repeatedly used in other tests and can be made reusable you could define it as a separate method. For example Login method is used by almost all the test cases. Creating a separate login test method enhances re-usability and avoids writing code from scratch each time.

For testing login method the test method should be separate and re-usable as below:
testLogin()

If you are defining a specific scenario that is seldom re-usable you can group up the verification points in a single method. Alan's suggestion is valuable in this case. Define a package say payment for all payment related testcases. Define a class for each payment test case say testShoppingPay, testRecurringPay. Inside each class you need to call a reusable method for initial setup. Write a testmethod for verification points involved.

It would look like:
testinitSetup() //Method for initial test case setup

test() //contains all verification points
{
testLogin() //Calls reusable login method
Assert(Element1Present)
Assert(Element2Present)
......
......
}