Re: [mongodb-user] Options for Running Automated Tests using MongoDB

345 views
Skip to first unread message

Octavian Covalschi

unread,
Aug 7, 2012, 1:38:17 PM8/7/12
to mongod...@googlegroups.com
I'm missing the part why do you need a maven mongodb plugin? I mean, maven would fire your integration tests and it's up to your settings where is mongodb instance running...

Is this a web app? Are you using spring?

PS: Starting and stopping a mongodb instance each time your tests run seems a bad practice. IMHO of course...

On Tue, Aug 7, 2012 at 12:25 PM, Andrew P <andrew...@stratus.com> wrote:
I'm starting development on a Java-based project that will be using MongoDB as its database, and I'm trying to figure out the best way to include some automated integration tests that use MongoDB. I build my project using Maven, and I'm using Jenkins as a continuous integration server.

My question is, what are some of the popular and best ways to do this? Since I've just recently started the project, I'm trying to stick to as many best practices as possible. Some plugins tell you to start and stop a MongoDB instance with each test, but it seems to me like that is pretty inefficient, since you can spend 1-2 seconds restarting MongoDB for each test.

I've seen that some people use the Embed Mongo plugin for Maven, but it seems like it doesn't have very much documentation:
https://github.com/joelittlejohn/embedmongo-maven-plugin

And I've seen that others use the MongoDB Integration Plugin for Maven, but it requires installing MongoDB on any server that will run the tests:
https://github.com/webmetrics/mongodb-integration-plugin

What do most people in this community use, and what is considered the best practice?

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

Andrew P

unread,
Aug 7, 2012, 2:00:28 PM8/7/12
to mongod...@googlegroups.com
A Maven plugin is not required, but the embedded MongoDB plugin seemed nice since it takes care of most of the work to start and stop MongoDB, and I wouldn't have to install MongoDB on the continuous integration server (not a big deal). Again, I'm not really tied to anything yet since I'm just getting started, so I'm just looking for opinions on what would/should be the best practice.

This is the backend for a web app, and I am not using spring.

Russell Bateman

unread,
Aug 7, 2012, 3:28:36 PM8/7/12
to mongod...@googlegroups.com
I use Mockito to squirrel-cage my DAO code (and test my business layer). It works perfectly. However, given than my DAO is a hodge-podge of half Morphia and half direct calls to the Java driver, I'd like to find a way to run tests on it even if I had to spin up an instance of MongoDB.

I'll watch this group attentively for suggestions too.

Octavian Covalschi

unread,
Aug 7, 2012, 3:36:44 PM8/7/12
to mongod...@googlegroups.com
I think it's a wrong mailing list to ask these kind of questions. Basically it gets to "how to run integration tests with junit"... 

Russell Bateman

unread,
Aug 7, 2012, 3:42:45 PM8/7/12
to mongod...@googlegroups.com
You're so right. And here I thought that the mongodb-user group was for MongoDB users, especially newcomers, to ask Mongo-related questions of anyone willing to share experience and give guidance.

Maxima mea culpa.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

Octavian Covalschi

unread,
Aug 7, 2012, 4:11:54 PM8/7/12
to mongod...@googlegroups.com
Russell,

Have you ever ran integration tests with regular databases? If yes, how did you do that?

Russell Bateman

unread,
Aug 7, 2012, 4:33:28 PM8/7/12
to mongod...@googlegroups.com
Yes, my friend, I do know better than that, but it doesn't explain why MongoDB, which is a very different kettle of fish, wouldn't have other testing support solutions than what are common in SQL land. If the answer is the same, that's cool. I think Andrew wasn't so much asking how to turn DB testing, an integration concept, into unit testing, but just what best practice was in the Mongo world for the fastest turn-around of whatever squirrel-caging solution there was to be had. As I'm soon going to be interested in hearing about it too, I thought I'd try to elicit a few more comments before settling back down into the attitude that Mongo didn't have anything magically better than the SQL world. As Mongo and its community so totally rocks, I would not have been surprised to learn that some cool solution had already been thought up. But one must usually ask or one doesn't hear about cool.

Best,
Russ
Reply all
Reply to author
Forward
0 new messages