2 Minutes To Code (β Version)

Mockito - 2 minute tutorial

Verify stubbed method - Basic

Mockito provides api to verify whether the stubbed method was called by the application or not.

Addiionally, it can verify the number of times a method was called as shown in the next page.
package com.techfundaes.mockitoBag;

import static org.mockito.Mockito.*;

import java.util.List;

public class VerifyMethodCalls
{
	public static void main(String[] args)
	{
		List myMockedList = mock(List.class); 
		
		myMockedList.get(0);
		myMockedList.clear();
		
		verify(myMockedList).get(0);
		verify(myMockedList).clear();
	}
}