Design for Testability Flashcards
1
Q
Is testability a functional requirement?
A
Nope, it’s just easier to test code like that
2
Q
What stops code from being testable?
A
- non-deterministic code
- hard/coding hiding behaviour
- overriding
- complex/slow configuration requirements
- Breaking the law of Demeter
3
Q
What is a test double?
A
A version of a production code object whose behaviour is predictable/controllable in a way that helps us write the test
4
Q
Type of test double?
A
Dummies: -passed around, never used, fill PARAMETER lists
Stubs:provide canned ANSWERS to calls made during the test
Fakes: working implementation but with shortcuts
Mocks:
Mock objects that mimic the behaviour of real objects in controlled ways (don’t worry about dependencies)