Integration tests with Embedded Mongo or the installed instance
Asked Answered
W

2

1

The application I am working on is a Velocity/Spring MVC/Mongo on tomcat kind of webapp.

I am able to run my integration tests on Embedded Mongo, using EmbedMongo which takes longer to run all the tests, say around 1 minutes but on the test database on installed Mongo, it takes around 15 secs.

Is there really any benefit in using Embedded databases for integration tests when creating a new db, (in this case a test db within the same instance) is a negligible effort ? In fact, the tests can themselves create the DB and required Collection.

Other than using Embedded Mongo on a CI box where the regular installation is not required, I don't see any great benefit in it.

Can anyone share any ideas please.

Thanks Gaurav

Warily answered 26/4, 2012 at 4:42 Comment(0)
C
1

Look at that link: https://mcmap.net/q/167191/-embedded-mongodb-when-running-integration-tests

It seems nice but the MongoDB is started and shutdown between each test.

What you may want to do, to increase speed, is to startup and shut down once for the whole test suite. I mean: keep the MongoDB instance up between tests.


But you don't want your tests to be dependant of each others. So what you could do is to use a different database name (UUID) so that in the end you have one MongoDB instance running, with many distinct databases, one for each test.

Or you can clean your database between each test.

Capet answered 5/1, 2013 at 12:55 Comment(0)
B
0

With a separate installed instance you have the process setup and teardown costs involved which you would want to minimize for your test suite hence the benefit of using Embedded DB.

Betrothal answered 26/4, 2012 at 17:24 Comment(1)
Yeah, that is true, but in case of Mongo, set up/ tear down cost is negligible. And on dev boxes, its always running so have another test db inside the same instance is a trivial achievement. So, I am still confused whether embedded mongo is a good ideaWarily

© 2022 - 2024 — McMap. All rights reserved.