
The JUnit 5 Handbook for Readable Fast Reliable Tests
A working reference to JUnit 5 and the JUnit 6 line: lifecycle, assertions, parameterized tests, extensions and the habits that keep suites fast.
Everything you need to level up your coding skills.

A working reference to JUnit 5 and the JUnit 6 line: lifecycle, assertions, parameterized tests, extensions and the habits that keep suites fast.

Decide what to unit test, what to run against real infrastructure and what to mock, with a layered plan that keeps a Spring Boot suite fast.

Find why a Spring Boot test cannot load its ApplicationContext, from a missing configuration class to a missing bean, property or database.

JUnit 5 is a Platform, an engine called Jupiter and a Vintage engine for old tests. See how they fit together and why it explains most setup errors.

Add JUnit 5 to a Maven or Gradle project, write a first test, run it from the command line and read the output, in about fifteen minutes.

See when BeforeAll, BeforeEach, AfterEach and AfterAll run, how nested classes and instance lifecycles change that order and how to control test order.

Use assertThrows to check the exception type and message, and assertAll to see every failure at once, with the mistakes that make both pass by accident.

Write assertions that say what they check and fail with a message you can act on, using JUnit 5 assertions and AssertJ's fluent style together.

Fix a Maven or Gradle build that reports zero tests by checking the Surefire version, test class names, imports and the JUnit Platform setting.

Fix the JUnit "No runnable methods" and initializationError failures caused by mixing JUnit 4 and JUnit 5 annotations or a wrongly configured runner.

Split fast and slow tests with JUnit Tag annotations, then select them in Maven Surefire and Failsafe or Gradle with tag expressions for CI stages.

Understand which Maven plugin runs which tests: Surefire for unit tests, Failsafe for integration tests, naming patterns, lifecycle phases and common fixes.
We send one email when a new post is published. No spam.