Tags » Mockito

Mock HibernateTemplate with Mockito


Mockito is a useful Java library to create mock Objects for Java Unit Testing.

I used the framework Mockito in order to test objects difficult to test otherwise such as Struts method, Servlet, Hibernate , etc… 338 more words

Non Classé

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. 200 more words


Different ways of using thenReturn

This post shows 3 different ways of using thenReturn.

1) First way involves configuring the mock object to return only one return value as shown below… 194 more words


Verifying the order of multiple instances method invocation

This post explains how to verify the order in which multiple instances are called. For example lets consider the below class


package package5;

public class Class2 {
    public void method1() {
        System.out.println("Class2 method1");
… 244 more words

Mocking a void method to throw an exception

This post will explain how to mock a public void method to throw an exception. Consider the below code


package package1;

public class Class1 {
    public void method1() {
… 104 more words

Improved matching error messages in Extended-Mockito

I’ve recently made some improvements to Extended-Mockito in the area of failure messages.

In early versions, messages from a failure to match in a verify() 161 more words