0

How to mock

SessionFactory sessionFactory = HibernateUtil.getSessionFactory()

using mockito?

maskacovnik
  • 3,080
  • 5
  • 20
  • 26
  • What @wjans said. Also you could have a look here: http://stackoverflow.com/questions/21105403/mocking-static-methods-with-mockito – Mindaugas Jul 14 '15 at 12:58

1 Answers1

2

You cannot mock a static method with Mockito. Have a look at PowerMock (PowerMockito). But note that it also has some drawbacks, like for instance performance.

wjans
  • 10,009
  • 5
  • 32
  • 43