TDD Resources
Design:
- They don’t put pressure to the design
- You can’t possibly test all cases
- Introduce “Collaboration” tests
- Introduce “Contract” tests
- Some tests are saying they’re Unit, but they’re actually Integration
- Good design is easy to test – Corey Haines
- Mockist vs Classist
- Mocks are isolated, fast & tell you about design flaws
- Messages to self – rarely tested
- Incoming messages – assert on result
- Outgoing messages – test for calling
- Outgoing queries – don’t test!
- Outgoing commands – expectations on mocks
Mocks:
- Mockist & behavior design VS Classist & STATE
- Mocks lead to better design that easy to change
- OO design is about interactions & roles
- Delegate the “How”
- Don’t let mocks depend on other mocks
- Mocks assert on messages
- Stub returns value
- Mock Roles, not concrete objects.
- Nested stubs are telling something about the design
- Good TDDers don’t write nested mocks
- We write huge functions because there’s no pressure of testing them
isolated.
- Isolated tests are microscope of object interactions
- Don’t let your tests make code less readable
- Don’t isolate “Collaborator” classes
- Mock only what you own
If you don’t own it, you don’t have control on it’s evolution
- Don’t mock just for speed
- Be aware that mocks introduce maintenance costs
- Keep mocks simple
- Mock rarely
Is TDD Dead?