This is because the type actually returned by SessionFactory.getCurrentSession() is org.hibernate.classic.Session , which is a subtype of org.hibernate.Session . You will need to change your layout to the correct type:
org.hibernate.classic.Session session = Mockito.mock(org.hibernate.classic.Session.class);
source share