Logic behind TestNG annotations

πŸ’‘Let's take example to understand it:

If in class have 2 test methods i.e 

@Test(priority=0)
public void googleSearch()
{}

@Test(priority=1)
public void googleSearch1()
{}

Then, result would be below:

@BeforeSuite & @AfterSuite

It will execute only once before all test methods and after all test methods.

@BeforeClass & @AfterClass

It will execute only once before all test methods and after all test methods.

@BeforeMethod & @AfterMethod

It will execute before and after each test methods. Means in above scenario, 2 methods then 2 times before and after method will get executed.

@BeforeTest & @AfterTest

It will execute only once before all test methods and after all test methods.

🎯 Good Luck for Your Learning..! πŸ™ 

Comments

Popular Post

MCQ questions for graphics class method in Java

Session 2 TestNG Framework | How to create TestNG Project In Eclipse IDE | With Selenium Test Cases

Print Hello World In Different Programming Languages | Boost Coding Skill | Developer Life

How to run Selenium script when system is locked?

Read Any Type Of JSON File in JAVA | Simple Introduction And Demo Of JavaScript Object Notation