Verifying the exact number of method invocations

This post explains how to verify that a method is executed desired number of times using Mockito framework. Below is the code of the class to be tested. Class1 code package package14; import java.util.List; public class Class1 { private List list; public void method1() { for(int i = 0; i < 10 ;i++) { list.add(i);…… Continue reading Verifying the exact number of method invocations

Verifying the order of multiple method invocations in a single instance

When multiple methods of single instance are invoked in an order in a class. We can verify the order of those method invocations using Mockito’s InOrder functionality. Consider the below code Class2 package package4; public class Class2 { public void method1() { System.out.println(“Class2 method1”); } public void method2() { System.out.println(“Class2 method2”); } public void method3()…… Continue reading Verifying the order of multiple method invocations in a single instance