Package com.redis.vl.test.vcr
Annotation Interface VCRTest
Enables VCR (Video Cassette Recorder) functionality for a test class.
When applied to a test class, this annotation enables automatic recording and playback of LLM API calls. This allows tests to run without making actual API calls after initial recording, reducing costs and providing deterministic test execution.
Example usage:
@VCRTest(mode = VCRMode.PLAYBACK)
class MyLLMIntegrationTest {
@Test
void testLLMResponse() {
// LLM calls are automatically intercepted
String response = chatModel.generate("Hello, world!");
assertThat(response).isNotEmpty();
}
}
Configuration options:
mode()- The VCR operating mode (default: PLAYBACK_OR_RECORD)dataDir()- Directory for storing cassettes (default: src/test/resources/vcr-data)redisImage()- Docker image for Redis container (default: redis/redis-stack:latest)
- See Also:
-
Optional Element Summary
Optional Elements
-
Element Details
-
mode
VCRMode modeThe VCR operating mode for this test class.- Returns:
- the VCR mode to use (default: PLAYBACK_OR_RECORD)
- Default:
PLAYBACK_OR_RECORD
-
dataDir
String dataDirThe directory where VCR cassettes (recorded responses) are stored.This directory will contain:
- dump.rdb - Redis RDB snapshot
- appendonlydir/ - Redis AOF segments
The directory is relative to the project root unless an absolute path is provided.
- Returns:
- the data directory path (default: src/test/resources/vcr-data)
- Default:
"src/test/resources/vcr-data"
-
redisImage
String redisImageThe Docker image to use for the Redis container.The image should be a Redis Stack image that includes RediSearch and RedisJSON modules for optimal functionality.
- Returns:
- the Redis Docker image name (default: redis/redis-stack:latest)
- Default:
"redis/redis-stack:latest"
-