New advertisers: 50% off your first month with code FIRSTMONTHSee slots

Unit tests for Spring cache annotations using an in-memory ConcurrentMapCacheManager and mocked repositories.

skills.sh installs
3.9K
GitHub stars
372
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers @Cacheable hit and miss behavior, @CacheEvict invalidation, @CachePut updates, and cache key generation from SpEL expressions
  • Includes Maven and Gradle dependency setup plus Java examples for service classes and their tests
  • Enforces checks that @EnableCaching is present and that calls pass through the Spring proxy rather than this
  • Designed for Spring Boot projects that want fast cache tests without Redis or a full application context

Install

$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-caching -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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

Details

Repository
github.com/giuseppe-trisciuoglio/developer-kit
Categories
Testing & QA, Java & JVM
First seen
May 16, 2026

More from giuseppe-trisciuoglio/developer-kit

All 95

Similar to Unit Test Caching

More Testing & QA