Scrum
PSD · Question #32
What are two reasons to use mock objects in unit tests?
The correct answer is A. The behavior of a given object can be emulated to the system under test E. Isolating a particular system component for controlled testing. Mock objects are simulating the behavior of dependencies such as persistance layers or APIs. By mocking these you can be sure about what you are testing, and not accidentally testing the external dependency.
Test Driven Development
Question
What are two reasons to use mock objects in unit tests?
Options
- AThe behavior of a given object can be emulated to the system under test
- BThey are machine-generated and eliminate the need to write code by hand
- CTo increase tight coupling
- DTDD is impossible without them
- EIsolating a particular system component for controlled testing
How the community answered
(22 responses)- A77% (17)
- B14% (3)
- C5% (1)
- D5% (1)
Explanation
Mock objects are simulating the behavior of dependencies such as persistance layers or APIs. By mocking these you can be sure about what you are testing, and not accidentally testing the external dependency.
Topics
#mock objects#test isolation#unit testing#dependency control
Community Discussion
No community discussion yet for this question.