Files
meeting-assistant/.agents/skills/tdd/references/interface-design.md
T
codex abac46c691
PR and Push Build/Test / build-and-test (push) Successful in 15m19s
Add repo TDD skill
2026-05-30 22:02:05 +02:00

32 lines
653 B
Markdown

# Interface Design for Testability
Good interfaces make testing natural:
1. **Accept dependencies, don't create them**
```typescript
// Testable
function processOrder(order, paymentGateway) {}
// Hard to test
function processOrder(order) {
const gateway = new StripeGateway();
}
```
2. **Return results, don't produce side effects**
```typescript
// Testable
function calculateDiscount(cart): Discount {}
// Hard to test
function applyDiscount(cart): void {
cart.total -= discount;
}
```
3. **Small surface area**
- Fewer methods = fewer tests needed
- Fewer params = simpler test setup