What is @AfterMethod?

@AfterMethod is one of the TestNG Annotations. As the name defines, @AfterMethod is executed after each test method within a test class. Suppose there are n test methods within a test class, then n times @AfterMethod annotated method will be invoked. This annotation allows developers to specify various actions to be taken after test methods are run.

TestNG @AfterMethod Annotations

The Concept Annotations is introduced in Java 1.5. The Popular Annotation in Java is @override. We use the same annotation concept in TestNG.

In TestNG, there are 10 Annotations:

In this article, we will learn about @AfterMethod.

Similar Reads

What is @AfterMethod?

@AfterMethod is one of the TestNG Annotations. As the name defines, @AfterMethod is executed after each test method within a test class. Suppose there are n test methods within a test class, then n times @AfterMethod annotated method will be invoked. This annotation allows developers to specify various actions to be taken after test methods are run....

Example of @AfterMethod

Let’s understand the @AfterMethod annotation through an example....