Tag Archives: hibernate

How to Mock a Hibernate Session with JMockit

I’m writing some unit tests with JUnit but my tests crash with NullPointerException in the line

Session session = sessionFactory.getCurrentSession();

There are also some session functions like flush and clear.

So I decided to write a mock object for that session, therefore tests can pass that line without got an exception.

Click to read more…

Tagged , ,