How do you test asynchronous methods with JUnit 5?
Wait on a real completion signal and bound it with a timeout. See CompletableFuture, @Async, @Timeout and Awaitility examples for reliable JUnit 5 async tests.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
Wait on a real completion signal and bound it with a timeout. See CompletableFuture, @Async, @Timeout and Awaitility examples for reliable JUnit 5 async tests.
@Timeout fails a JUnit 5 test, lifecycle method or class of tests that exceeds a time limit, protecting builds from hangs and deadlocks.
Benchmark Spring code with JMH and measure live latency with Micrometer and Actuator, with warm-up, forks and result-quality tips.
Create, read, update and delete Redis data in Spring Boot with CrudRepository and RedisTemplate, including TTLs, JSON serializers and the cache abstraction.
RedisTemplate gives Spring applications a typed, thread-safe API for Redis data structures, serialization, pipelining and transactions.
Configure RedisTemplate and StringRedisTemplate in Spring Boot with correct serializers, TTL and examples for strings, lists, hashes and pipelines.
The spring-boot-starter-data-redis dependency adds Spring Data Redis and a Redis client, and auto-configures templates for caching, data storage and messaging.
Use Redis as a Spring Boot cache with @Cacheable and TTLs, then store entities with @RedisHash repositories and avoid common caching mistakes.
Learn the ways to write custom queries in Spring Data JPA: @Query, native SQL, derived methods, @Modifying updates and dynamic Specifications.
Pageable carries page number, size and sort; Page returns the content with total counts. See repository, controller and performance examples.
@Table tells JPA which table an entity maps to and lets you set the schema, unique constraints and indexes. Learn each attribute with working examples.
@OneToMany, @ManyToOne and @ManyToMany map entity relationships to foreign keys and join tables. See examples, fetch defaults, cascading rules and common mistakes.
Map one-to-one, one-to-many, many-to-one and many-to-many relationships in JPA, and learn the owning side, mappedBy, fetch types and cascade rules.
Extend JpaRepository for your entity and Spring Data generates CRUD, paging and query methods for you. This guide covers setup and examples.
SpringExtension is the JUnit 5 extension that loads Spring contexts and injects beans into tests. Learn when you need it and how it differs from SpringRunner.
Learn to build JUnit 5 extensions with lifecycle callbacks, parameter resolvers and conditions, and register them with @ExtendWith or @RegisterExtension.
@ExtendWith registers JUnit Jupiter extensions on tests. See Mockito and Spring usage, a custom extension, parameter injection and how it replaces @RunWith.
@Nested lets you organise JUnit 5 tests into inner classes with their own setup and display names. Includes a full example and lifecycle order.
@BeforeEach and @AfterEach set up and clean up every JUnit 5 test. See practical patterns with Mockito and databases, plus ordering rules and pitfalls.
Learn Mockito verification: verify call counts, arguments with ArgumentCaptor, call order with InOrder, and how to avoid brittle over-verified tests.