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. He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

You may also like...

Leave a Reply

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