Recall & Review
beginner
What is a test double in software testing?
A test double is a simplified object that stands in for a real object during testing to isolate the code being tested.
Click to reveal answer
beginner
Name the four common types of test doubles.
The four common types are: Dummy, Stub, Mock, and Spy.
Click to reveal answer
beginner
When should you use a Dummy test double?
Use a Dummy when you need to pass an object but it is not used by the test, just to satisfy method parameters.
Click to reveal answer
intermediate
What is the main purpose of a Stub?
A Stub provides predefined responses to calls made during the test, controlling indirect inputs to the system under test.
Click to reveal answer
intermediate
How does a Mock differ from a Stub?
A Mock not only provides predefined responses but also verifies that certain interactions happened, like method calls with specific arguments.
Click to reveal answer
Which test double is used only to fill parameter lists but is never actually used in the test?
✗ Incorrect
A Dummy is a placeholder object passed to satisfy method signatures but not used in the test.
Which test double helps control indirect inputs by returning fixed data during tests?
✗ Incorrect
A Stub returns predefined data to control the behavior of the system under test.
Which test double verifies that specific methods were called with expected arguments?
✗ Incorrect
Mocks verify interactions, such as method calls and arguments, during the test.
If you want to record how a real object was used during a test, which test double would you use?
✗ Incorrect
A Spy records information about how it was called, allowing verification after the test.
Which test double should you choose if you only want to isolate the tested code without verifying interactions?
✗ Incorrect
Stubs isolate the tested code by providing controlled responses without verifying calls.
Explain the differences between Dummy, Stub, Mock, and Spy test doubles and when to use each.
Think about their roles in controlling inputs and verifying behavior.
You got /4 concepts.
Describe a real-life example where choosing the right test double improves test reliability.
Consider how test doubles help avoid dependencies and make tests faster.
You got /3 concepts.