Skip to content
Sharp

Project Structure · interview question

In Mockito, which method is used to verify that a mock object's method was called a specific number of times?

Multiple choiceHardchapter-10-curatedpremiumproject-structurejava-modules-jpms
Choose one answer
Answer and explanation

Correct answer

B. Verify(mock, times(n)).methodName()

Why

The 'verify' method in Mockito is used to check interactions with a mock object. The 'times(n)' argument specifies the expected number of invocations for the method being verified.

Test yourself on Project Structure

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

Start free test
All Project Structure questions →