TestNG annotations divide into three categories:
Precondition Annotations: The annotations under this category execute before the test. It consists of the following annotations:
@BeforeMethod
@BeforeClass
@BeforeSuite
@BeforeTest
Test Annotations: The annotations under this category are defined just before the test methods. Moreover, it consists of the following annotations:
@Test
Postcondition Annotations: The annotations under this category execute after the test methods. Additionally, it consists of the following annotations:
@AfterMethod
@AfterClass
@AfterTest
@AfterSuite
Subsequently, you can learn more about it here, How to use TestNG annotations using Selenium.