Multi-module test support framework for Embabel Agent applications providing integration testing, mock AI services, and test configuration utilities
A comprehensive multi-module test support framework for Embabel Agent applications. Test AI agent applications without requiring actual LLM API calls or API keys.
New to this framework? Start here:
Need to use a specific feature?
Working on a specific task?
Want to understand the modules?
Looking for advanced patterns?
Need reference information?
The Embabel Agent Test Support framework enables comprehensive testing of AI agent applications without requiring actual LLM API calls or API keys. It provides three complementary modules that work independently or together based on your testing needs.
embabel-agent-test-support (parent POM)
├── embabel-agent-test → Mockito integration testing
├── embabel-agent-test-common → Fake AI services
└── embabel-agent-test-internal → Spring test configurationMockito-based integration testing for agent applications.
Use when: Writing integration tests that need to mock LLM operations and verify agent behavior.
Key capability: Stub and verify LLM text generation and object creation.
Learn more: Integration Testing Module
Fake implementations of AI services for testing without API calls.
Use when: Testing embedding operations, vector storage, or semantic search without real AI services.
Key capability: Generate fake embeddings with configurable dimensions.
Learn more: Fake AI Services Module
Spring test configuration and testing utilities.
Use when: Setting up Spring Boot tests with complete fake AI infrastructure or testing custom model configurations.
Key capability: Provides pre-configured fake LLM and embedding service beans.
Learn more: Test Configuration Module
See Installation for dependency configuration.
Here's a complete integration test using all three modules:
import com.embabel.agent.test.integration.EmbabelMockitoIntegrationTest;
import com.embabel.common.test.ai.config.FakeAiConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.beans.factory.annotation.Autowired;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest
@Import(FakeAiConfiguration.class)
public class MyAgentTest extends EmbabelMockitoIntegrationTest {
@Autowired
private LlmService<?> cheapest;
@Autowired
private EmbeddingService embeddingService;
@Test
void testCompleteAgentFlow() {
// Stub LLM operations
whenGenerateText(prompt -> prompt.contains("analyze"))
.thenReturn("Analysis complete");
// Execute agent with fake services
var result = agentPlatform.executeFlow(input, cheapest, embeddingService);
// Verify interactions
verifyGenerateText(prompt -> prompt.contains("analyze"));
assertNotNull(result);
}
}Next steps: Your First Test
Stubbing allows you to control what the LLM returns in your tests:
// Stub text generation
whenGenerateText(prompt -> prompt.contains("hello"))
.thenReturn("Hello, world!");
// Stub object creation
whenCreateObject(prompt -> prompt.contains("extract"), Person.class)
.thenReturn(new Person("John"));Learn more: Stubbing API | Stubbing Guide
Verification allows you to assert that the LLM was called with expected inputs:
// Verify text generation occurred
verifyGenerateText(prompt -> prompt.contains("expected"));
// Verify object creation occurred
verifyCreateObject(prompt -> prompt.contains("extract"), Person.class);Learn more: Verification API | Verification Guide
Fake services provide test implementations that work without API calls:
// Create fake embedding model
val embeddingModel = FakeEmbeddingModel(dimensions = 1536)
// Generate test embeddings
val embedding = embeddingModel.embed(Document("test content"))
// Returns random 1536-dimensional embeddingLearn more: FakeEmbeddingModel API | Testing Embeddings Guide
Spring test configuration provides pre-configured fake beans:
@SpringBootTest
@Import(FakeAiConfiguration::class)
class MyTest {
@Autowired
private lateinit var cheapest: LlmService<*> // Fake gpt-4o-mini
@Autowired
private lateinit var best: LlmService<*> // Fake gpt-4o
@Autowired
private lateinit var embeddingService: EmbeddingService // Fake embeddings
}Learn more: Test Configuration API | Spring Test Setup Guide
@Test
void testAgentGeneratesText() {
whenGenerateText(p -> p.contains("summarize"))
.thenReturn("This is a summary");
String result = myAgent.summarize(document);
verifyGenerateText(p -> p.contains("summarize"));
assertEquals("This is a summary", result);
}@Test
void testAgentExtractsData() {
Person expected = new Person("Alice", 30);
whenCreateObject(p -> p.contains("extract"), Person.class)
.thenReturn(expected);
Person result = myAgent.extractPerson(text);
verifyCreateObject(p -> p.contains("extract"), Person.class);
assertEquals(expected, result);
}@Test
fun `test semantic search without API`() {
val embeddingModel = FakeEmbeddingModel(dimensions = 768)
val searchEngine = SemanticSearchEngine(embeddingModel)
searchEngine.indexDocuments(listOf("doc1", "doc2", "doc3"))
val results = searchEngine.search("query", topK = 2)
assertEquals(2, results.size)
}@Test
fun `test feature works with all model tiers`() {
val cheapResult = feature.execute(input, cheapModel)
val bestResult = feature.execute(input, bestModel)
// Both should succeed
assertNotNull(cheapResult)
assertNotNull(bestResult)
}More examples: Common Tasks | Testing Patterns
Understanding how the modules relate:
All modules are designed to work independently or together based on your testing needs.
Learn more: Architecture Reference
| Feature | Module | Description |
|---|---|---|
| Stub LLM text generation | embabel-agent-test | Control text responses in tests |
| Stub LLM object creation | embabel-agent-test | Control structured outputs in tests |
| Verify LLM calls | embabel-agent-test | Assert LLM was called correctly |
| Fake embeddings | embabel-agent-test-common | Generate test embeddings without API |
| Fake LLM services | embabel-agent-test-internal | Pre-configured fake cheapest/best models |
| Options converter testing | embabel-agent-test-internal | Test model configuration converters |
I want to...