🔥 Live 2,847 QA engineers learning right now — Start Free Automation Roadmap →

TestNG Visualizer

This free TestNG visualizer makes the one thing everyone gets asked in interviews crystal clear: the exact order TestNG annotations run in. It also shows groups, priorities, parallel execution and data providers. Built for SDETs who want to stop guessing the annotation order and explain it with confidence.

↓ Open the tool

Annotation execution order

TestNG runs annotations in a fixed order that you should be able to recite: @BeforeSuite@BeforeTest@BeforeClass@BeforeMethod@Test@AfterMethod@AfterClass@AfterTest@AfterSuite. The before hooks fire outermost-first and the after hooks fire innermost-first, wrapping each test method.

Priorities, dependencies and groups

priority orders tests (lower runs first; same priority runs alphabetically). dependsOnMethods skips a test if its dependency failed. Groups tag tests (@Test(groups="smoke")) so a suite XML can include or exclude them — the TestNG equivalent of Cucumber tags.

Data providers: data-driven testing

A @DataProvider method returns a set of rows, and TestNG runs the test once per row. This is the clean way to test many inputs without duplicating test methods, and it is the standard TestNG interview answer for data-driven testing.

Parallel execution

TestNG can run methods, classes or tests in parallel via the suite XML (parallel="methods" thread-count="4"). This is a major reason large Selenium suites use TestNG — but your tests must be thread-safe (no shared mutable driver), which is exactly why teams use a ThreadLocal WebDriver.

How to use this tool

  1. Run the sample suite and watch each annotation fire in order.
  2. Add priorities to test methods and see the order change.
  3. Attach a data provider and watch the test repeat per data row.
  4. Enable parallel execution and see methods run on multiple threads.

Worked example

A data-driven TestNG test runs once per row returned by the provider:

@DataProvider(name = "logins")
public Object[][] logins() {
    return new Object[][] {
        {"admin", "pass1"},
        {"user",  "pass2"}
    };
}

@Test(dataProvider = "logins")
public void login(String user, String pass) {
    loginPage.login(user, pass);
    Assert.assertTrue(homePage.isLoaded());
}
TestNG calls login() once for each row, so two data sets become two test runs.

Common mistakes to avoid

Frequently asked questions

What is the execution order of TestNG annotations?

@BeforeSuite, @BeforeTest, @BeforeClass, @BeforeMethod, then @Test, then @AfterMethod, @AfterClass, @AfterTest, @AfterSuite — before hooks wrap each test outermost-first, after hooks innermost-first.

How does priority work in TestNG?

Lower priority values run first; methods with the same priority run in alphabetical order. Priority only orders @Test methods.

What is a DataProvider?

A method that supplies multiple rows of data so TestNG runs the same test once per row — TestNG's built-in data-driven testing.

How do you run TestNG tests in parallel?

Configure parallel and thread-count in the suite XML (by methods, classes or tests). Your tests must be thread-safe, typically via a ThreadLocal WebDriver.

Is this TestNG tool free?

Yes, it runs in your browser with nothing to install and is free for learning and interview prep.

Related guides & tools