
How to Detect N plus 1 Queries in Tests Automatically
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.
Integration tests with real databases, Mockito, Testcontainers and how much of each is worth writing.

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.

Write a correct Java microbenchmark with JMH: project setup, state classes, Blackhole, warmup, forks, avoiding dead code elimination and reading the results.

Test a Spring Kafka consumer against a real broker in Testcontainers: send a record, wait for the effect, and cover retries and the dead letter topic.

Define unit, integration and end-to-end tests in a Java service by what each one starts, what it can catch and what it costs to run.

Wire Testcontainers into Spring Boot tests with @ServiceConnection: no dynamic properties, supported containers, local development with TestApplication.

Mock HTTP dependencies with WireMock in JUnit: stubbing responses, verifying requests, simulating delays and faults, scenarios and Spring integration.

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

Make tests deterministic by injecting Clock, a Random seed and an id supplier, instead of calling now, Math.random and UUID.randomUUID inside the code.

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

Test Spring MVC controllers with MockMvc and WebMvcTest: status, JSON, validation, security, uploads and exception handlers without a server.

Write readable API tests with REST Assured: given when then, JSON path checks, request specs, authentication, schema validation and Spring Boot setup.
We send one email when a new post is published. No spam.