JUnit 5 set-up and clean-up methods, parameterized tests and disabled tests
Run one test with many inputs instead of copying it, set up and tidy once or every time, and skip a test with a reason instead of deleting it.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: one exam question asked with three answer sheets. The desk is cleared before each sheet. If a question is withdrawn, the paper says why. You do not write the question three times.
Tom reuses a case with declared inputs while managing setup and intentional non-execution. A lifecycle method prepares or releases resources at its named boundary. stands for comma-separated values. A CSV source supplies parameterized cases. A is reported as not executed, not as passing behavior.
The exam sheets and stage-crew pictures are alternative reminders: prepare for each invocation, keep the expected answer explicit, and record why a scene or question is not being performed.
The picture has a limit. Lifecycle behavior depends on the selected instance mode and extensions. Input parsing can change the values before the test sees them; a disabled test supplies no evidence that its business assertion currently passes.
(SYNTHETIC / TRAINING ONLY: Daily List and every named person are invented.)
PLAIN WORDS · 4 in this section
- reuses
- uses again
- parameterized
- sending values apart from the command so they cannot alter
- invocation
- switching on the backup plan when the main system fails
- parsing
- reading text and splitting it into its parts
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 Manage Jupiter invocation and class lifecycles with meaningful parameterized and disabled-test outcomes.
- Crew
- Cards
- Crossed out
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The crew before each scene | A before-each method |
| Opening the theatre once | A before-all method |
| A cue card for each acting of one scene | A parameter value |
| A scene crossed out in the script | A skipped test |
WHERE THIS PICTURE STOPS
- Class-level reuse can share mutable state; setup boundaries and cleanup ownership matter.
- CSV parsing can change inputs, and disabled does not mean the behavioral assertion passed.
HOOK
Crew, cards, crossed out.
TELL A FRIEND
A crew, cue cards and a crossed-out scene.
OFTEN MIXED UP WITH JUnit 5 from zero: first tests, set-up methods and assertions. That topic writes the first tests and checks. This one removes copies with parameterized tests, adds once-only set-up and skips a test with a reason.
Sources & standards — 5 sources
- Implementation-specific
JUnit 5.14.4 test instance lifecycle ↗ — JUnit team · Default per-method mode; per-class mode and non-static class callbacks; configurable defaults (selected actual primary passages read 7 November 2026; named JUnit5.14.4 or Surefire3.6.1 scope, not latest-version certification).
Actual selected primary sections read. The active guide header selects5.14.4; version-picker entries and newer-version notice are not its version. CSV introductory prose discrepancy is explained against attribute semantics/default and concrete false example. Synthetic helper/data examples do not claim application validation. Isolated runtime tests, if reported, do not certify Maven or every JVM.
- Implementation-specific
JUnit 5.14.4 disabling tests ↗ — JUnit team · Method-level disabling versus class instantiation and class-level callbacks (selected actual primary passages read 7 November 2026; named JUnit5.14.4 or Surefire3.6.1 scope, not latest-version certification).
Actual selected primary sections read. The active guide header selects5.14.4; version-picker entries and newer-version notice are not its version. CSV introductory prose discrepancy is explained against attribute semantics/default and concrete false example. Synthetic helper/data examples do not claim application validation. Isolated runtime tests, if reported, do not certify Maven or every JVM.
- Implementation-specific
JUnit 5.14.4 parameterized tests ↗ — JUnit team · CSV source input parsing/table; invocation lifecycle and BeforeEach per invocation (selected actual primary passages read 7 November 2026; named JUnit5.14.4 or Surefire3.6.1 scope, not latest-version certification).
Actual selected primary sections read. The active guide header selects5.14.4; version-picker entries and newer-version notice are not its version. CSV introductory prose discrepancy is explained against attribute semantics/default and concrete false example. Synthetic helper/data examples do not claim application validation. Isolated runtime tests, if reported, do not certify Maven or every JVM.
- Implementation-specific
JUnit 5.14.4 CsvSource API ↗ — JUnit team · Quoted/unquoted whitespace and empty fields; explicit boolean semantics/default and prose discrepancy (selected actual primary passages read 7 November 2026; named JUnit5.14.4 or Surefire3.6.1 scope, not latest-version certification).
Actual selected primary sections read. The active guide header selects5.14.4; version-picker entries and newer-version notice are not its version. CSV introductory prose discrepancy is explained against attribute semantics/default and concrete false example. Synthetic helper/data examples do not claim application validation. Isolated runtime tests, if reported, do not certify Maven or every JVM.
- Implementation-specific
JUnit 5.14.4 annotations ↗ — JUnit team · Jupiter test and lifecycle annotation roles (selected actual primary passages read 7 November 2026; named JUnit5.14.4 or Surefire3.6.1 scope, not latest-version certification).
Actual selected primary sections read. The active guide header selects5.14.4; version-picker entries and newer-version notice are not its version. CSV introductory prose discrepancy is explained against attribute semantics/default and concrete false example. Synthetic helper/data examples do not claim application validation. Isolated runtime tests, if reported, do not certify Maven or every JVM.
PRACTISE AND KEEP
Sources for this topic — 5 sources
- Implementation-specific
JUnit 5.14.4 test instance lifecycle ↗ — JUnit team · Default per-method mode; per-class mode and non-static class callbacks; configurable defaults (selected actual primary passages read 7 November 2026; named JUnit5.14.4 or Surefire3.6.1 scope, not latest-version certification).
Actual selected primary sections read. The active guide header selects5.14.4; version-picker entries and newer-version notice are not its version. CSV introductory prose discrepancy is explained against attribute semantics/default and concrete false example. Synthetic helper/data examples do not claim application validation. Isolated runtime tests, if reported, do not certify Maven or every JVM.
- Implementation-specific
JUnit 5.14.4 disabling tests ↗ — JUnit team · Method-level disabling versus class instantiation and class-level callbacks (selected actual primary passages read 7 November 2026; named JUnit5.14.4 or Surefire3.6.1 scope, not latest-version certification).
Actual selected primary sections read. The active guide header selects5.14.4; version-picker entries and newer-version notice are not its version. CSV introductory prose discrepancy is explained against attribute semantics/default and concrete false example. Synthetic helper/data examples do not claim application validation. Isolated runtime tests, if reported, do not certify Maven or every JVM.
- Implementation-specific
JUnit 5.14.4 parameterized tests ↗ — JUnit team · CSV source input parsing/table; invocation lifecycle and BeforeEach per invocation (selected actual primary passages read 7 November 2026; named JUnit5.14.4 or Surefire3.6.1 scope, not latest-version certification).
Actual selected primary sections read. The active guide header selects5.14.4; version-picker entries and newer-version notice are not its version. CSV introductory prose discrepancy is explained against attribute semantics/default and concrete false example. Synthetic helper/data examples do not claim application validation. Isolated runtime tests, if reported, do not certify Maven or every JVM.
- Implementation-specific
JUnit 5.14.4 CsvSource API ↗ — JUnit team · Quoted/unquoted whitespace and empty fields; explicit boolean semantics/default and prose discrepancy (selected actual primary passages read 7 November 2026; named JUnit5.14.4 or Surefire3.6.1 scope, not latest-version certification).
Actual selected primary sections read. The active guide header selects5.14.4; version-picker entries and newer-version notice are not its version. CSV introductory prose discrepancy is explained against attribute semantics/default and concrete false example. Synthetic helper/data examples do not claim application validation. Isolated runtime tests, if reported, do not certify Maven or every JVM.
- Implementation-specific
JUnit 5.14.4 annotations ↗ — JUnit team · Jupiter test and lifecycle annotation roles (selected actual primary passages read 7 November 2026; named JUnit5.14.4 or Surefire3.6.1 scope, not latest-version certification).
Actual selected primary sections read. The active guide header selects5.14.4; version-picker entries and newer-version notice are not its version. CSV introductory prose discrepancy is explained against attribute semantics/default and concrete false example. Synthetic helper/data examples do not claim application validation. Isolated runtime tests, if reported, do not certify Maven or every JVM.
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.