Testing¶
kmongo-dsl-testcontainers provides a MongoDB server shared by all the tests of a JVM, started with
Testcontainers (Docker required)
as a single node replica set: transactions and change streams are available.
testImplementation("org.litote.kmongo:kmongo-dsl-testcontainers")
val client = KMongo.createClient(KMongoTestServer.connectionString)
val database = client.getDatabase(KMongoTestServer.newDatabaseName())
- the image is set with the
kmongo.test.mongodb.imagesystem property (defaultmongo:8.2) - set the
kmongo.test.mongodb.urisystem property (or theKMONGO_TEST_MONGODB_URIenvironment variable) to use an existing server instead of a container