TestNG Execution Hierarchy (Ordered List)
🔹 Before Test Execution (Setup Methods)
1️⃣ @BeforeSuite → Runs once before everything in the test suite.
2️⃣ @BeforeTest → Runs before all tests in a <test> block (testng.xml).
3️⃣ @BeforeClass → Runs before the first test method in the class.
4️⃣ @BeforeMethod → Runs before every test method (@Test).
🔹 Test Execution (Test Methods)
5️⃣ @Test → Executes test methods in priority order or alphabetically.
🔹 After Test Execution (Teardown Methods)
6️⃣ @AfterMethod → Runs after every test method (@Test).
7️⃣ @AfterClass → Runs after all test methods in the class.
8️⃣ @AfterTest → Runs once after all tests in a <test> block (testng.xml).
9️⃣ @AfterSuite → Runs once after everything in the test suite.
✅ Follows a Top-to-Bottom Execution Order.

Comments
Post a Comment