Skip to content
Sharp

Testing · interview question

In the context of using Mockito, what does the method 'verify()' do?

Multiple choiceEasychapter-10-curatedpremiumtestingmocking-with-mockito
java
verify(mockPaymentGateway).processPayment(any());
Choose one answer
Answer and explanation

Correct answer

D. Checks if a method was called with specific arguments

Why

The 'verify()' method in Mockito is used to confirm that a particular method was called on a mock object with specified arguments. This is useful for ensuring that the behavior of the code under test aligns with expectations.

Test yourself on Testing

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

Start free test
All Testing questions →