Magnolia uses JUnit 4 tests and Mockito (new) for creating unit tests. Before we were using EasyMock for dynamic mocks.
Independently from that make sure your tests match our conventions. Information on how to best migrate JUnit3-style tests to JUnit4 can be found here.
Mockito is a more recent mocking library. We'll not bulk convert existing EasyMock-Tests as this would be to big an effort. Instead we set up the following rules:
- all new tests requiring dynamic mocks use Mockito
- whenever you touch (fix, adapt, complete) an existing test that's using EasyMock: convert it to Mockito
Since Magnolia 4.5 we provide the package info.magnolia.test.mock.jcr containing proper mock's for javax.jcr.Node, javax.jcr.Session etc. They're extending abstract types provided in jackrabbit-commons. The types of the Content API are now basically just wrapping these new mocks. If required you can always create a MockContent from a MockNode or a MockHierarchyManager from a MockSession.
With the help of info.magnolia.test.mock.jcr.SessionTestUtil MockNodes can be created from properties files
as well as from String:
Of course there's also an proper API for it: