Provides patterns for unit testing Spring Cache annotations (@Cacheable, @CachePut, @CacheEvict). Generates test code that mocks cache managers, verifies cache…
Testing Spring Cache annotations without external infrastructure using in-memory cache managers. Covers testing @Cacheable, @CacheEvict, and @CachePut annotations with patterns for verifying cache hits, misses, and invalidation Uses ConcurrentMapCacheManager for fast, isolated unit tests instead of Redis or other external caches Includes verification strategies via mock call counts, conditional caching with unless and condition parameters, and custom cache key generation with SpEL expressions Provides setup examples for Maven and Gradle, plus complete test patterns for cache behavior, eviction, updates, and edge cases like null result handling Unit Testing Spring Caching Overview This skill provides patterns for unit testing Spring caching annotations (@Cacheable, @CacheEvict, @CachePut) without full Spring context. It covers cache hits/misses, invalidation, key generation, and conditional caching using in-memory ConcurrentMapCacheManager. When to Use Writing unit tests for @Cacheable method behavior Verifying @CacheEvict cache invalidation works correctly Testing @CachePut cache updates Validating cache key generation from SpEL expressions Testing conditional caching with unless/condition parameters Mocking cache managers in fast unit tests without Redis Instructions
don't have the plugin yet? install it then click "run inline in claude" again.