Event Flow E2E Testing (The Work Nobody Wants to Do)
The Context: After building a CRM domain layer with event sourcing, we had unit tests, integration
tests, even some event flow tests. But we didn’t have comprehensive end-to-end verification that events
actually flow correctly through the entire system.Why this matters: In event-sourced systems, bugs in event flow are catastrophic:
Miss an event → audit trail broken
Wrong event order → state corruption
Cross-tenant event leak → compliance violation
The traditional problem: Writing E2E tests for event flows is tedious:
Set up test infrastructure (EventBridge, SQS, DynamoDB Streams)
Create test data for each entity type
Trigger actions and wait for async event delivery
Verify event payload, ordering, and side effects
Clean up test resources
Repeat for every entity and workflow combination
Estimated manual effort: 2-3 weeks for comprehensive coverageWhat I tried: Give the entire task to AI.
Planning session for comprehensive E2E event flow testing.Context:- Event-sourced CRM with 7 entities (Account, Contact, Lead, Opportunity, Activity, Product, Address)- Events flow: DynamoDB Streams → EventBridge → SQS → Consumers- Need to verify event delivery, ordering, and payload correctness- Must test cross-entity workflows (e.g., Lead conversion)Requirements:1. Test each entity's event flow independently2. Test multi-entity workflows (create Account → add Contact → convert Lead)3. Test failure scenarios (event delivery failure, consumer errors)4. All tests must run against LocalStack (no AWS resources)Design comprehensive test suite with:- Test data fixtures- Event verification utilities- Async event waiting helpers- Clear assertion patterns
Evaluator (Opus) produced a 24-page plan with:Test Architecture:
Events from previous tests could pollute later tests
Fix: Added per-test event queue isolation
The result: Comprehensive E2E event testing that would have taken 2-3 weeks manually, done in 1.5 days
with AI.But more importantly: I actually have confidence in the event system now. Without AI, I would’ve
written 3-4 “smoke tests” and hoped for the best.
Key Insight: AI makes thorough testing economically viable. The marginal cost of going from
“some tests” to “comprehensive coverage” dropped from weeks to hours.
Principle 1: AI Excels at Systematic Test Coverage
What we learned: Work that requires consistent application of testing patterns across many cases is
perfectly suited for AI.Example: 21 E2E test scenarios following same pattern in 1.5 daysRule: If testing requires “do the same validation many times consistently,” delegate entirely to AI.Anti-pattern: Using AI for exploratory testing (AI needs clear success criteria).
Principle 2: Testing Becomes Worth Doing
What we learned: Comprehensive testing that was “too expensive” manually becomes “obviously worth it” with AI.Example: E2E event flow testing
Manual estimate: 2-3 weeks (not worth it)
With AI: 1.5 days (absolutely worth it)
Result: Testing quality improved not because AI writes better tests, but because comprehensive testing
became economically viable.Rule: Re-evaluate “not worth the effort” decisions when AI changes the effort equation.
Principle 3: Test Coverage ≠ Requirement Coverage
What we learned: Builder wrote tests that covered code paths but didn’t map to requirements.Practice: Every test must reference a requirement in the test name.Example:
Copy
#[test]fn test_account_name_validation_per_prd_section_2_1() { // Test specific requirement from PRD}