Results 1 to 3 of 3

Thread: Best practices for mocking Repository

  1. #1
    Join Date
    Dec 2011
    Posts
    3

    Default Best practices for mocking Repository

    Hi all,

    First of all sorry for the double posting (I asked this in the NOSQL forum wiht no luck some days ago)

    I've started using the MongoDb Spring Data and I have some services with references to different Repository interfaces (extending PagingAndSortingRepository).

    I'd like to unit test these services injecting repository doubles or mocks.

    Does Spring Data / MongoDb provide any testing facilities in these regards? Are there any practices to follow in this field or should I create my own mocks?

    Many thanks in advance

  2. #2
    Join Date
    Dec 2011
    Location
    United States
    Posts
    1

    Default

    "I'd like to unit test these services injecting repository doubles or mocks."
    it is not possible.

  3. #3
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    493

    Default

    Why shouldn't it? As the repositories are interfaces only you can easily exchange them using a general purpose mocking library like Mockito, EasyMock or jMockit. Have a look at the Spring Data test cases for a general impression of how to use Mockito for example.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •