Mock Objects, Test Suites, TDD Flashcards
What is a mock object?
Cheap placeholder objects sued to set up certain test conditions.
In brief, when do we use a mock object?
When the object being tested has dependencies.
In detail, what are the 6 characteristics that prompt the use of Mock Objects?
Object is slow; Non-deterministic; Complex to set up; Doesn’t exist yet; Is a GUI, Has hard to trigger behaviour.
From which interface should mock objects be implemented?
The same interface as from which the production code was.
What is a test suite?
A construct that allows us to run multiple, independent tests as a single batch of tests.
What is the purpose of categories in test suites?
Categories are the concept that enables the grouping of unit tests.
From which perspective is TDD implemented?
The users perspective.
What are the 2 main benefits of TDD?
Users perspective; Write better code.
What do we do is a unit test is overly complex to test?
Re-design the code being tested.
Define invariants…
An assertion on an object that doesn’t change. Object state should always be consistent.