TOPIC 34/4016 MINNOT STARTED

TestNG: groups, parameters and data providers

Run the same Java test with many inputs, pick which tests run, and share setup. Learn the TestNG features that go past a single JUnit-style test.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: a playlist. A playlist lets you play a few songs for a short drive and all of them for a long one. You do not change the songs, only the list.

A song can sit on more than one playlist.

A group is a playlist of tests. Tom, the tester at Daily List, a to-do list app, plays the smoke list before every push. The aim is to change what runs without changing the tests themselves.

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB A playlist you choose for a short drive or a long one.

  1. Group
  2. Pick
  3. Run
Playlist

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
The playlistA test group
The songsThe tests
Playing one song many waysA data provider
The settings pageA suite file

WHERE THIS PICTURE STOPS

  • A playlist plays in order, but a group does not set order.
  • A song is the same each time, but a row changes the input.
  • A playlist is yours, but a suite file is shared.

HOOK

Choose the list, play it.

TELL A FRIEND

A playlist: pick the list, not the songs.

OFTEN MIXED UP WITH Test runners: JUnit, TestNG and pytest. That topic compares three runners. This one goes deep on TestNG groups and data providers.

PRACTISE AND KEEP

Sources for this topic — 2 sources
  1. Market practice

    Annotations (TestNG documentation) ↗ — TestNG · TestNG documentation: groups are set on a test and the run can include or exclude groups by name, and setup and cleanup methods can run before or after a group (search excerpt, page not opened)

    The official page listing the TestNG annotations, including the test, group, setup and data provider annotations. Official project documentation. · Checked 2026-11-06

    Primary publisher body opened and relevant sections read on 6 November 2026; selected-section reading, not a claim every page or external link was read. See docs/research/v16-testing-automation-literacy-audit-20261106.md for exact sections, version and limitations.

  2. Market practice

    Parameters (TestNG documentation) ↗ — TestNG · TestNG documentation: a data provider is a method that returns rows of values and a test names it, so the test runs once for each row (search excerpt, page not opened)

    The official page on passing values from the suite file and from data provider methods into tests. Official project documentation. · Checked 2026-10-31

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.