Testing Overview
Erdo provides two complementary testing approaches that enable comprehensive validation while minimizing API costs: unit testing for logic validation and integration testing for end-to-end verification.Testing Philosophy
Agent systems present unique testing challenges:- Complexity: Multiple execution paths through conditional logic and result handlers
- State Validation: Ensuring data flows correctly through templates and steps
- Coverage: Identifying and testing all possible paths through the agent
- Integration Costs: LLM API calls in integration tests can accumulate
- Declarative structure that enables automatic path enumeration
- Static analysis that validates templates before execution
- Intelligent caching for cost-effective integration testing
- Parallel execution for rapid feedback
Test Types Comparison
Erdo provides two distinct test types, each serving different purposes:| Aspect | Unit Tests (erdo test) | Integration Tests (erdo agent-test) |
|---|---|---|
| What it does | Validates agent structure & logic locally | Executes agents with real backend/LLM calls |
| Backend calls | ❌ None - pure static analysis | ✅ Yes - actual execution |
| Speed | ⚡ 2-5 seconds for full coverage | 🐢 Depends on LLM response time (or fast with replay cache) |
| Cost | 💰 Free - no API calls | 💰 First run costs API fees, replay mode caches for free reruns |
| Coverage | 🔍 All execution paths (2^n for n conditions) | 🎯 Specific test scenarios you write |
| Use case | Validate logic, catch template errors, rapid development | End-to-end validation, integration verification |
| When to run | Every save/commit - instant feedback | Before deployment, CI/CD, regression testing |
| Test files | Any agent Python file | Functions with agent_test_* prefix |
| Command | erdo test my_agent.py | erdo agent-test tests/test_my_agent.py |
Quick Decision Guide:
- Use Unit Tests when you want fast feedback on agent structure, template syntax, and execution paths
- Use Integration Tests when you need to validate actual LLM behavior and end-to-end functionality
- Use Both for comprehensive coverage: unit tests catch structure issues instantly, integration tests validate real behavior
Unit Testing
Local Validation Only: Unit tests run entirely on your machine with NO backend or LLM calls. They’re free, fast, and perfect for rapid development iteration. See the Unit Testing Guide for complete details.
Overview
Unit tests validate agent structure and logic through static analysis and path enumeration:What Gets Tested
Execution Path Enumeration Because Erdo agents are declarative, the CLI can automatically identify all execution paths:- All conditional branches (success/error handlers)
- ITERATE_OVER loops with different data structures
- Step dependencies and ordering
- Handler combinations
- State field availability and access patterns
- Type compatibility
- Parameter hydration with test data
- Missing key detection
- Step output accumulation
- Data transformations
- Context availability at each step
Example Output
Running Unit Tests
Test Data Generation
Erdo automatically generates test data from your parameter definitions:Integration Testing
Live Agent Execution: Integration tests execute your agents with real backend and LLM calls. Use replay mode to cache responses and minimize API costs. See the Integration Testing Guide for complete details on modes and best practices.
Overview
Integration tests execute agents with real LLM calls. They support three modes (live, replay, manual) for different testing needs:Replay Mode
Replay mode intelligently caches LLM responses: First Execution- Executes agent with real LLM calls
- Caches responses locally
- Test runs with actual API behavior
- Returns cached responses without API calls
- Tests run in milliseconds instead of seconds
- Identical behavior to first execution
- Automatic when agent definition changes
- Manual refresh with
--refreshflag - Per-test cache isolation
Test Modes
- Replay Mode (Recommended)
- Live Mode
- Manual Mode
- Most integration tests
- CI/CD pipelines
- Regression testing
- Rapid development iteration
- First run: Real API calls, response cached
- Subsequent runs: Cached response, no API calls
- Deterministic test results
Running Integration Tests
Test Helpers
Test Organization
File Structure
Naming Convention
Best Practices
Test Coverage Strategy
- Unit Tests: Validate all execution paths
- Integration Tests: Test critical user journeys
- Edge Cases: Handle error conditions and boundary cases
- Regression Tests: Prevent known issues from recurring
Cost-Effective Testing
Continuous Integration
Performance Characteristics
Unit Tests
- Duration: 2-5 seconds for comprehensive path coverage
- Cost: No API calls
- Coverage: All execution paths automatically tested
Integration Tests with Replay Mode
- First Run: Standard API call duration + caching overhead
- Subsequent Runs: Milliseconds (cached responses)
- Cost: API costs only on first run or cache refresh
- Parallelism: 10x faster with parallel execution
Integration Tests with Live Mode
- Duration: Standard API call duration per test
- Cost: API costs per execution
- Use Case: Strategic validation only