
JUnit Extension Model Explained With Custom Examples
Understand the JUnit Jupiter extension model: extension points, ExtendWith, parameter resolvers, callbacks and conditions, with three custom examples.
Everything you need to level up your coding skills.

Understand the JUnit Jupiter extension model: extension points, ExtendWith, parameter resolvers, callbacks and conditions, with three custom examples.

Find and fix flaky Java tests: detect them with reruns and random order, learn the causes with examples and quarantine safely.

Write composed annotations in JUnit 5 with meta annotations: combine tags, extensions and display names into reusable test annotations for cleaner test code.

Set timeouts with @Timeout and assertTimeout in JUnit 5, understand threading differences, and handle flaky tests without hiding real bugs through retries.

Run JUnit 5 from Gradle: useJUnitPlatform, dependencies with the BOM, test filtering, logging, parallel forks, tags and reports for CI.

Write parameterized tests in JUnit 5 with ParameterizedTest, ValueSource, NullSource, EnumSource and a display name, and know when a table is clearer.

Run JUnit tests only when a condition holds: EnabledOnOs, EnabledForJreRange, EnabledIfEnvironmentVariable, EnabledIf and custom ExecutionCondition.

Create and clean up temporary files in JUnit with TempDir, share a directory per class, load files from test resources and avoid fragile paths in tests.

Fix Mockito's UnnecessaryStubbingException by removing dead stubs, moving setup into the tests that use it and using lenient stubs only where they belong.

Inject your own objects into JUnit 5 test methods and constructors with ParameterResolver, and combine it with lifecycle callbacks to manage resources.

Use Mockito spy to stub part of a real object, learn the doReturn syntax, and see why a spy often signals a class that should be split instead.

Turn on parallel test execution in JUnit 5: the configuration properties, execution modes, @Isolated and resource locks, and the shared state that breaks.
We send one email when a new post is published. No spam.