0
0
JUnittesting~5 mins

Why different doubles serve different purposes in JUnit - Quick Recap

Choose your learning style9 modes available
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 control behavior and isolate tests.
Click to reveal answer
beginner
What is the main purpose of a Dummy object?
A Dummy object is passed around but never actually used. It just fills parameter lists to satisfy method signatures.
Click to reveal answer
intermediate
How does a Stub differ from a Dummy in testing?
A Stub provides predefined responses to calls made during the test, allowing control over indirect inputs, unlike a Dummy which is unused.
Click to reveal answer
intermediate
What role does a Mock play in unit testing?
A Mock not only simulates behavior but also verifies that certain interactions (like method calls) happened as expected during the test.
Click to reveal answer
advanced
Why use different types of test doubles instead of just one?
Different test doubles serve different purposes: Dummies fill parameters, Stubs control indirect inputs, Mocks verify behavior, making tests clearer and more focused.
Click to reveal answer
Which test double is used only to fill parameter lists and is never actually used?
AMock
BStub
CDummy
DSpy
Which test double provides canned responses to method calls during testing?
AStub
BMock
CDummy
DFake
Which test double verifies that certain methods were called during the test?
ADummy
BMock
CStub
DFake
Why might you choose a Stub over a Mock in a test?
ATo provide canned responses without verifying calls
BTo replace the entire system
CTo fill unused parameters
DTo verify method calls
What is the main benefit of using different test doubles?
ATo avoid writing tests
BTo make tests slower
CTo confuse developers
DTo isolate tests and clarify their purpose
Explain the differences between Dummy, Stub, and Mock test doubles and when to use each.
Think about how each double helps control or verify behavior in tests.
You got /3 concepts.
    Why is it important to choose the right type of test double in unit testing?
    Consider how different doubles affect test focus and reliability.
    You got /4 concepts.