tdd-london-chicago
π―Skillfrom proffesor-for-testing/agentic-qe
Guides developers in selecting and applying London (mock-based) or Chicago (state-based) test-driven development strategies for effective testing.
Installation
npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill tdd-london-chicagoSkill Details
"Apply London (mock-based) and Chicago (state-based) TDD schools. Use when practicing test-driven development or choosing testing style for your context."
Overview
# Test-Driven Development: London & Chicago Schools
When implementing TDD or choosing testing style:
- IDENTIFY code type: domain logic β Chicago, external deps β London
- WRITE failing test first (Red phase)
- IMPLEMENT minimal code to pass (Green phase)
- REFACTOR while keeping tests green (Refactor phase)
- REPEAT cycle for next functionality
Quick Style Selection:
- Pure functions/calculations β Chicago (real objects, state verification)
- Controllers/services with deps β London (mocks, interaction verification)
- Value objects β Chicago (test final state)
- API integrations β London (mock external services)
- Mix both in practice (London for controllers, Chicago for domain)
Critical Success Factors:
- Tests drive design, not just verify it
- Make tests fail first to ensure they test something
- Write minimal code - no features beyond what's tested
Quick Reference Card
When to Use
- Starting new feature with test-first approach
- Refactoring legacy code with test coverage
- Teaching TDD practices to team
- Choosing between mocking vs real objects
TDD Cycle
| Phase | Action | Discipline |
|-------|--------|------------|
| Red | Write failing test | Verify it fails, check message is clear |
| Green | Minimal code to pass | No extra features, don't refactor |
| Refactor | Improve structure | Keep tests passing, no new functionality |
School Comparison
| Aspect | Chicago (Classicist) | London (Mockist) |
|--------|---------------------|------------------|
| Collaborators | Real objects | Mocks/stubs |
| Verification | State (assert outcomes) | Interaction (assert calls) |
| Isolation | Lower (integrated) | Higher (unit only) |
| Refactoring | Easier | Harder (mocks break) |
| Design feedback | Emerges from use | Explicit from start |
Agent Coordination
qe-test-generator: Generate tests in both schoolsqe-test-implementer: Implement minimal code (Green)qe-test-refactorer: Safe refactoring (Refactor)
---
Chicago School (State-Based)
Philosophy: Test observable behavior through public API. Keep tests close to consumer usage.
```javascript
// State verification - test final outcome
describe('Order', () => {
it('calculates total with tax', () => {
const order = new Order();
order.addItem(new Product('Widget', 10.00), 2);
order.addItem(new Product('Gadget', 15.00), 1);
expect(order.totalWithTax(0.10)).toBe(38.50);
});
});
```
When Chicago Shines:
- Domain logic with clear state
- Algorithms and calculations
- Value objects (
Money,Email) - Simple collaborations
- Learning new domain
---
London School (Mock-Based)
Philosophy: Test each unit in isolation. Focus on how objects collaborate.
```javascript
// Interaction verification - test method calls
describe('Order', () => {
it('delegates tax calculation', () => {
const taxCalculator = {
calculateTax: jest.fn().mockReturnValue(3.50)
};
const order = new Order(taxCalculator);
order.addItem({ price: 10 }, 2);
order.totalWithTax();
expect(taxCalculator.calculateTax).toHaveBeenCalledWith(20.00);
});
});
```
When London Shines:
- External integrations (DB, APIs)
- Command patterns with side effects
- Complex workflows
- Slow operations (network, I/O)
---
Mixed Approach (Recommended)
```javascript
// London for controller (external deps)
describe('OrderController', () => {
it('creates order and sends confirmation', async () => {
const orderService = { create: jest.fn().mockResolvedValue({ id: 123 }) };
const emailService = { send: jest.fn() };
const controller = new OrderController(orderService, emailService);
await controller.placeOrder(orderData);
expect(orderService.create).toHaveBeenCalledWith(orderData);
expect(emailService.send).toHaveBeenCalled();
});
});
// Chicago for domain logic
describe('OrderService', () => {
it('applies discount when threshold met', () => {
const service = new OrderService();
const order = service.create({ items: [...], total: 150 });
expect(order.discount).toBe(15); // 10% off > $100
});
});
```
---
Common Pitfalls
β Over-Mocking (London)
```javascript
// BAD - mocking everything
const product = { getName: jest.fn(), getPrice: jest.fn() };
```
Better: Only mock external dependencies.
β Mocking Internals
```javascript
// BAD - testing private methods
expect(order._calculateSubtotal).toHaveBeenCalled();
```
Better: Test public behavior only.
β Test Pain = Design Pain
- Need many mocks? β Too many dependencies
- Hard to set up? β Constructor does too much
- Can't test without database? β Coupling issue
---
Agent-Assisted TDD
```typescript
// Agent generates tests in both schools
await Task("Generate Tests", {
style: 'chicago', // or 'london'
target: 'src/domain/Order.ts',
focus: 'state-verification' // or 'collaboration-patterns'
}, "qe-test-generator");
// Agent-human ping-pong TDD
// Human writes test concept
const testIdea = "Order applies 10% discount when total > $100";
// Agent generates formal failing test (Red)
await Task("Create Failing Test", testIdea, "qe-test-generator");
// Human writes minimal code (Green)
// Agent suggests refactorings
await Task("Suggest Refactorings", { preserveTests: true }, "qe-test-refactorer");
```
---
Agent Coordination Hints
Memory Namespace
```
aqe/tdd/
βββ test-plan/* - TDD session plans
βββ red-phase/* - Failing tests generated
βββ green-phase/* - Implementation code
βββ refactor-phase/* - Refactoring suggestions
```
Fleet Coordination
```typescript
const tddFleet = await FleetManager.coordinate({
workflow: 'red-green-refactor',
agents: {
testGenerator: 'qe-test-generator',
testExecutor: 'qe-test-executor',
qualityAnalyzer: 'qe-quality-analyzer'
},
mode: 'sequential'
});
```
---
Related Skills
- [agentic-quality-engineering](../agentic-quality-engineering/) - TDD with agent coordination
- [refactoring-patterns](../refactoring-patterns/) - Refactor phase techniques
- [api-testing-patterns](../api-testing-patterns/) - London school for API testing
---
Remember
Chicago: Test state, use real objects, refactor freely
London: Test interactions, mock dependencies, design interfaces first
Both: Write the test first, make it pass, refactor
Neither is "right." Choose based on context. Mix as needed. Goal: well-designed, tested code.
With Agents: Agents excel at generating tests, validating green phase, and suggesting refactorings. Use agents to maintain TDD discipline while humans focus on design decisions.
More from this repository10
Automates security vulnerability scanning and penetration testing for n8n workflows, identifying potential risks and misconfigurations.
Validates database schemas, tests data integrity, verifies migrations, checks transaction isolation, and measures query performance.
Delivers unvarnished technical criticism with surgical precision, combining expert-level BS detection and zero-tolerance for low-quality work.
n8n-expression-testing skill from proffesor-for-testing/agentic-qe
Validates n8n workflow triggers by comprehensively testing webhook, schedule, polling, and event-driven mechanisms with robust payload and authentication checks.
Validates n8n integration connectivity, authentication flows, and error handling across external service APIs through comprehensive testing patterns.
Applies Six Thinking Hats methodology to systematically analyze software testing challenges from multiple perspectives, enhancing decision-making and test strategy development.
Provisions and manages consistent, cost-effective test environments using Docker, Kubernetes, and infrastructure as code for reliable software testing.
Prioritizes testing efforts by systematically assessing and ranking risks based on probability and potential impact across software components.
context-driven-testing skill from proffesor-for-testing/agentic-qe