# 3.3 Sample TestNG Class

Create a New Class Named SimpleTestNGClassExample in Eclipse. and copy paste the below code to the class. Run the Script by right Clicking anywhere in the code editor and click "Run As" > TestNG Test. Please note the option "Run As > TestNG" won't appear if you don't have testNG plugins. Follow this tutorial to install testng plugins.

```
package com.selenium;

import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class SimpleTestNGClassExample {

    @BeforeTest
    public void initialization() {
        System.out.println("This method will be executed once before the"+ "testMethod gets called..");
        System.out.println("All the statements like browser setup, "
        + "data-variable Initilization etc. should be done here..");
    }

    @Test
    public void testMethod() {
        System.out.println("This method will be called after the setup method" + "is called..");
        System.out.println("All the statements related to test execution" + "Should appear here..");
    }

    @AfterTest
    public void cleanup() {
        System.out.println("This method will be called after all previous methods"+ "are executed..");
        System.out.println("All the statements related to clean up/closure activity should be listed here..");
    }

}
```

Testng works by looking for Annotation in the code, name @BeforeTest, @Test, @AfterTest and so on. The code in these annotations is run sequentially.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://n-saikiran.gitbook.io/selenium-2-web-driver-basics/3.-testing-frameworks-for-selenium/3.3-sample-testng-class.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
