| Quick Reference JUnit CheatsheetJUnit 5 on one page — Jupiter tests, lifecycle, assertions, parameters, and the traps around argument order, arrays, and static state. 10 sections 10 tables 14 code snippets A Jupiter testExpected, then actual Static import What runs
This page is JUnit 5 Jupiter. Mockito and Spring test slices are left out. LifecycleFresh cart before each test Once per class When each hook runs
AssertionsWhole values Array contents Which method
ExceptionsType, then the call What the matcher accepts
Several checksKeep going after one miss One failure or all of them
ParametersOne method, three inputs Where the arguments come from
AssumptionsSkip when the machine cannot run this Skip versus fail
Nested classesA group inside the outer test Inner class rules
Names and orderTurn @Order on Labels, skips, sequence
Interview trapsMessage last The JUnit 4 import Traps worth memorising
How to use this page: use Jupiter annotations, put the expected value first, and keep mutable state off static fields. |