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..! 🙏