Mockito – Verifying Method Calls

By | October 15, 2020

We can use org.mockito.Mockito.verify(T mock) method to ensure whether a mock() method was called with required arguments or not. In other words, we can say that Mockito.verify(T mock) is used to confirm that specific interactions took place.

Let’s try to understand the above concept using a demo project

pom.xml

 

MyUtils.java

 

MyUtilsTest.java 

 

The Output of the above project:

 

You May Also Like:

What is Mocking?
Why Need for mocking?
What are the Benefits of Mockito?
How to mock interface using Mockito example?
Mockito and JUnit Integration Using Maven Example
@Mock and @Spy Mockito Annotations With Example
@InjectMocks Annotation in Mockito with Example
@Captor Annotation in Mockito with Example
Adding behavior to mocked object in Mockito
Mocking Void Methods with Mockito
Mocking Exception Throwing using Mockito
Mockito’s mock Overloaded Methods

That’s all about Mockito – Verifying Method Calls
If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *