Skip to content
Sharp

Testing · interview question

In a Mockito test, what is the purpose of using 'verifyNoMoreInteractions()' on a mock object?

Multiple choiceHardchapter-10-curatedpremiumtestingmocking-with-mockito
Choose one answer
Answer and explanation

Correct answer

A. To ensure no additional methods were called on the mock

Why

The 'verifyNoMoreInteractions()' method is used to confirm that no other methods were called on the mock object beyond those already verified. This helps catch unintended interactions, ensuring the test remains focused on specific expected behaviors.

Test yourself on Testing

A free test with instant, explained results. No account needed.

Start free test
All Testing questions →