Design For Testability Flashcards
code that is easy to test..
is code that is well designed
what is testability
a non functional requirement
easy to test
what is design for testability
testability concerns drive the design
what are difficulties in design for testability.
non deterministic code
hard coded/hidden behaviour
not allowing inheritance/override
complex/slow configurations
breaking the law of demeter
what is the law of demeter
principle of least knowledge
only limited knowledge about other units:
Only talk to immediate friends.
what is a test double
version of code object whose behaviour is predictable and controllable
describe a dummy
passed around but never used
describe a stub
provide canned answers to calls
describe fakes
have implementations but take short cuts
describe mocks
created on the fly
behaviour matches programmed expectations.
fixed return values
can verify behaviour, such as number of calls
what is design for testibility
allows us to predict behaviour and plan for it from the start. All classes have at least two clients from the start.