From beca9c1f9e7b86ae108479bbe72fc9f0ad1165c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Mon, 6 Jul 2026 10:46:45 +0200 Subject: [PATCH] test: Dump collections when a test fails --- test/src/commonMain/kotlin/Utils.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/src/commonMain/kotlin/Utils.kt b/test/src/commonMain/kotlin/Utils.kt index 8fcdfcd3..40b2a947 100644 --- a/test/src/commonMain/kotlin/Utils.kt +++ b/test/src/commonMain/kotlin/Utils.kt @@ -18,6 +18,7 @@ package opensavvy.ktmongo.tests.api import opensavvy.ktmongo.api.MongoClient import opensavvy.prepared.suite.Prepared +import opensavvy.prepared.suite.cleanUp import opensavvy.prepared.suite.prepared import opensavvy.prepared.suite.random.randomInt @@ -26,7 +27,16 @@ val testId by randomInt(0, Int.MAX_VALUE) inline fun Prepared.collection( prefix: String, ) = prepared { - this@collection() + val collection = this@collection() .database("ktmongo-integration-tests") .collection("$prefix-${testId()}") + + cleanUp("Dump collection ${collection.fullyQualifiedName}", onSuccess = false) { + println("First 100 documents:") + collection.find(options = { limit(100) }, filter = {}).forEach { + println(" • $it") + } + } + + collection } -- 2.51.2