TestNG Tutorial #3 – TestNG Annotations | BeforeMethod vs BeforeTest

In this TestNG tutorial we will learn about TestNG Annotations, BeforeMethod vs BeforeTest and AfterMethod vs AfterTest. We will understand with example how to use TestNG annotations @BeforeTest, @AfterTest, @BeforeMethod @AfterMethod in your test scripts.

✅ @BeforeTest: The method annotated with @BeforeTest annotation will be executed before any test method belonging to the classes inside the “test” tag is run.

✅ @AfterTest: The method annotated with @AfterTest annotation will be executed after all the test methods belonging to the classes inside the “test” tag have run.

✅ @BeforeMethod: The method annotated with @BeforeMethod annotation will be executed before each test method.

✅ @AfterMethod: The method annotated with @AfterMethod annotation will be executed after each test method.

TestNG Tutorial #9 – TestNG Annotations | BeforeGroups | BeforeClass

In this TestNG tutorial we will learn about TestNG Annotations, BeforeGroups, BeforeClass, AfterGroups and AfterClass.

We will understand with example how to use TestNG annotations @BeforeGroups, @AfterGroups @BeforeClass and @AfterClass in your test scripts.

✅ @BeforeClass: The method annotated with @BeforeClass will be executed before the first test method in the current class is invoked.

✅ @AfterClass: The method annotated with @AfterClass will be executed after all the test methods in the current class have been run.

✅ @BeforeGroups: The method annotated with @BeforeGroups is guaranteed to run shortly before the first test method that belongs to any of the groups configured in this method.

✅ @AfterGroups: The method annotated with @AfterGroups is guaranteed to run shortly after the last test method that belongs to any of thee groups configured in this method.