Pick the fix
A repository test mocks DAO calls one by one and breaks whenever the implementation changes, even when results are the same. What's better?
Hint 1 of 1
What should the test check: calls or results?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Use a fake DAO (or an in-memory Room database) and assert on results
Correct. The test checks behaviour, not the order of internal calls.
Why not the others?
- B Mock more methods. Even more brittle.
- C Use reflection to call private methods. Tests implementation details.
- D Skip repository tests. Loses coverage.