What does the reset() method do in Mockito?
A) It resets the mocks to their default state
B) It verifies that the mock was called
C) It initializes a new mock object
D) It cleans up resources after a test
Answer:
A) It resets the mocks to their default state
Explanation:
The reset()
method in Mockito is used to reset the mocks to their default state. This means that all interactions, stubbings, and verifications on the mock are cleared, making it as if the mock was just created.
This can be useful in scenarios where you want to reuse a mock in multiple tests within the same test class, but you need to ensure that previous configurations and interactions do not interfere with the current test.