Q:

Configure & use mongodb mockup server for unit testing

I have to develop some Junit tests for Java code using a MongoDB store.  Is there any framework/library which permits me initializing a mock in-memory MongoDB server? 
(The idea is to test only the code itself, that means, in any machine independently on if MongoDB is installed & running). 
Thanks in advance! 

A:

fongo might be what you are looking for. 

A:

I wrote a MongoDB fake implementation in Java: mongo-java-server (see this answer). 

A:

We're actually working on such a test system and it's quite feasible.  In our approach our test framework extends the standard test case class (JUnit in our case but TestNG seems more capable) that sets up and tears down the various database dependecies with each test using the following steps :
Test Suite Setup
1) Start mongod process (we use ProcessBuilder, store Process instance)
Test Setup :
2) Run mongo with a test specific .js file to produce initial data state
Test
3) Run test
Test Teardown
4) Drop database
Test Suite Teardown
5) Stop mongod process (process.destroy())
Since starting and stopping mongod is the only time consuming thing i'd strongly suggest doing this as little as possible.  Preferably once for the entire test suite.  Our stuff isn't finished yet but early results are positive.  I don't think many alternatives are available.  No mongo mock library is available at time of writing and mongod does not have a in-memory/embedded mode.