
How to Write Readable Assertions With JUnit 5 and AssertJ
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.
Everything you need to level up your coding skills.

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.

A rule for choosing what to mock in Java tests: replace what you do not own or cannot run cheaply, and keep real the code whose behavior you are testing.

Fix the Testcontainers error about a missing Docker environment by starting the daemon, pointing at the right socket and updating an old client.

Tell dummies, stubs, spies, mocks and fakes apart with a Java example of each, and learn which one to reach for in a given test.

What the test pyramid says, why it fits business logic and fits badly for services that mostly connect a database to a queue, and what to draw instead.

Use Spring Boot test slices properly: WebMvcTest, DataJpaTest, JsonTest and RestClientTest load only part of the context, with mocks, imports and speed gains.

Detect N plus 1 queries in Java tests: count statements with Hibernate statistics or datasource-proxy and fail the build when a budget is exceeded.

Understand Spring test context caching: what the cache key contains, how to see hits and misses, limit the cache size and design tests to share contexts.

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.