Recall & Review
beginner
What is a fake object in testing?
A fake object is a simple implementation of an interface or class used in tests to simulate real behavior with minimal logic. It helps isolate the code under test by replacing complex dependencies.Click to reveal answer
intermediate
How does a fake object differ from a mock?
A fake object has working implementations but simplified, while a mock is used to verify interactions and expectations during tests.
Click to reveal answer
beginner
Why use fake objects in JUnit tests?
They speed up tests by avoiding slow or complex real components, and help test code in isolation without external dependencies.
Click to reveal answer
intermediate
Example of a fake object in JUnit for a payment service?
class FakePaymentService implements PaymentService { public boolean pay(double amount) { return true; } } This fake always returns success to test payment logic without real transactions.Click to reveal answer
beginner
What is a key benefit of using fake objects over real implementations in tests?
They make tests faster, more reliable, and easier to write by removing dependencies on external systems or complex logic.
Click to reveal answer
What is the main purpose of a fake object in testing?
✗ Incorrect
Fake objects simulate real components with minimal logic to isolate tests and improve speed.
Which of the following is true about fake objects?
✗ Incorrect
Fake objects provide simplified working implementations to replace real dependencies in tests.
In JUnit, why might you use a fake object instead of the real service?
✗ Incorrect
Fake objects avoid external dependencies and make tests faster and more reliable.
Which is NOT a characteristic of a fake object?
✗ Incorrect
Verifying method calls is a feature of mocks, not fake objects.
What would a fake payment service likely do in a test?
✗ Incorrect
A fake payment service usually returns success to test payment logic without real transactions.
Explain what a fake object is and why it is useful in JUnit testing.
Think about replacing complex parts with simple versions in tests.
You got /4 concepts.
Describe the difference between a fake object and a mock in software testing.
One simulates behavior, the other checks calls.
You got /4 concepts.