Skip to content
Exposed docs1.11

Exposed R2DBC Test Support

Latest stable Based on Exposed release 1.11.0

Suspending transaction, schema/table lifecycle, R2DBC driver, assertion, and Testcontainers fixtures.

R2DBC tests must prove coroutine transaction propagation, driver behavior, cleanup after suspension/failure, and real dialect behavior. Reusing JDBC-only fixtures leaves the most important R2DBC boundaries untested.

Use it for R2DBC repository, query, driver, cancellation, and framework integration tests. It is a test dependency, not an application runtime module.

testImplementation("io.github.bluetape4k.exposed:bluetape4k-exposed-r2dbc-tests"), managed by the central BOM.

withDb acquires the per-database semaphore without blocking a coroutine worker, opens a maxAttempts = 1 suspendTransaction, and restores temporary configuration. withTables and withSchemas create, commit, and clean up fixtures; schema cleanup preserves the primary failure and suppresses a secondary drop failure.

withTables(TestDB.POSTGRESQL, Actors) {
Actors.insert { it[name] = "Ada" }
Actors.selectAll().count() shouldBeEqualTo 1L
}
TaskAPI
Suspending transaction fixturewithDb
Table/schema lifecyclewithTables, withSchemas
Auto-commit probewithAutoCommit
R2DBC database matrixTestDB, configs and container helpers
Shared assertions/schemaassertion and shared packages

Collect database flows inside the fixture transaction. Test the deployed R2DBC driver with its matching Testcontainer. Add bounded cancellation tests and assert cleanup before the next test uses the same database.

The module exposes R2DBC SPI/pool, H2/MariaDB/MySQL/PostgreSQL R2DBC drivers, JUnit 5, and Testcontainers support for tests.

Choose TestDB, driver options, and optional DatabaseConfig per fixture. Temporary database references are restored after execution.

Collecting after the fixture closes loses transaction context. Blocking semaphore acquisition on a coroutine worker reduces test concurrency; the fixture moves that acquisition to Dispatchers.IO. Cleanup failures must not replace the original assertion failure.

Capture driver/container logs, coroutine timeout, and pool state on failure. Bound every test so a driver cancellation defect cannot hang the suite indefinitely.

The module tests transaction fixtures, DDL cleanup, assertions, shared schemas, and SQL behavior. Consumer tests should add rollback, cancellation, partial-flow collection, and dialect-specific cases.

Apply it after Coroutine transactions, then follow Cancellation and testing.

The fixture cannot guarantee that a particular driver cancels server-side work. It does not model production pool load or replace long-running resilience tests.

These diagrams are loaded directly from README assets published with the 1.11.0 release and pinned to its immutable commit. They describe this manual’s released structure and runtime flows, not later Snapshot changes. Select a preview to open the SVG at the same release commit.

Test Infrastructure Structure diagram

Release README: exposed/r2dbc-tests/README.md

withTables R2DBC test lifecycle diagram

Release README: exposed/r2dbc-tests/README.md