Test runners: JUnit, TestNG and pytest
A runner finds your tests, runs them, and reports results. Learn what JUnit, TestNG and pytest do the same and where they differ.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a referee. A referee starts the match, tracks each play and writes the score. The players do the playing.
A referee also blows the whistle for the start and the end.
A is the referee for tests. Tom, the tester at Daily List, a to-do list app, writes the checks, and the runner runs them and writes the score.
The picture is only a first way in. It will not fit every detail, so the next levels give the exact words and show where the picture stops working.
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 Finding tests, running them and reporting the score, like a referee.
- Find
- Run
- Report
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The referee | The runner |
| A play | A test |
| The score | The report |
| Getting the pitch ready | The fixture |
WHERE THIS PICTURE STOPS
- A referee decides, but a runner only reports.
- A match has one ball, but tests can run in parallel.
- A referee sees the match, but a runner sees only the checks.
HOOK
Find, run, report.
TELL A FRIEND
A referee: start the match, track each play and write the score.
OFTEN MIXED UP WITH Automation frameworks overview. That topic maps the kinds of automation frameworks. This one looks at the runner inside them.
PRACTISE AND KEEP
Sources for this topic — 3 sources
- Market practice
JUnit 5 user guide (JUnit documentation) ↗ — JUnit team · JUnit 5 user guide: tests are methods marked with annotations and run by the JUnit platform (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page for the 5.14.0 guide as listed in a search; read as a search excerpt only. 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.
- Market practice
TestNG documentation (Welcome to TestNG) ↗ — TestNG project · TestNG documentation: TestNG is a testing framework with annotations, grouping, parameters and reports (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read as a search excerpt only. 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.
- Market practice
Get started (pytest documentation) ↗ — pytest development team · pytest documentation: pytest finds functions whose names start with test and reports failed assertions with detail (search excerpt, page not opened)
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.