unit-test-caching
CommunityTest Spring caching behavior efficiently.
AuthorMassimilianoPili
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This Skill enables developers to thoroughly test Spring's caching annotations (@Cacheable, @CacheEvict, @CachePut) in isolation, ensuring cache logic functions correctly without requiring a full Spring context or external caching infrastructure.
Core Features & Use Cases
- Test Cache Hit/Miss: Verify that data is cached after the first call and retrieved from the cache on subsequent calls.
- Test Cache Invalidation: Ensure data is removed from the cache when using @CacheEvict.
- Test Cache Updates: Confirm that @CachePut correctly updates the cache with new data.
- Test Conditional Caching: Validate caching behavior based on conditions or when results are null.
- Test Cache Key Generation: Verify that the correct cache keys are generated for different method arguments.
- Use Case: You've implemented caching in your
UserServiceto improve performance. Use this Skill to write unit tests that confirm a user is fetched from the database only on the first request and from the cache on subsequent requests for the same user ID.
Quick Start
Write a JUnit test to verify that calling getUserById(1L) twice results in the underlying repository being called only once.
Dependency Matrix
Required Modules
None requiredComponents
references
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: unit-test-caching Download link: https://github.com/MassimilianoPili/claude-code-config/archive/main.zip#unit-test-caching Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.