Execution Sequence of Annotations in TestNG

In the previous post, we have seen how to execute a set of test cases using Test Suite. In this post, we will learn about the sequence of annotations.

Till now, we have seen the working of @AfterMethod,@BeforeMethod and @Test. Apart from these ,there are so many other annotations as well. There might be some scenarios where you may have to use all or might be during automation framework development.

So, it is important to understand the sequence in which all annotations will be executed. Let’s understand with a pictorial presentation first as given below, then we will understand how to use them in a program.

Execution Sequence of Annotations in TestNG:

Execution sequence of annotations in TestNG

 

Example of annotations sequence: 

Output: 

Annotations execution in TestNG


Ask Question
Have any question or suggestion for us?Please feel free to post in Q&A Forum

 

Building a Test Suite in TestNG
Prioritizing of Test Cases in TestNG
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...

1 Response

  1. pavan says:

    Nice work

Leave a Reply

Your email address will not be published. Required fields are marked *