Exposed R2DBC Test Support
Latest stable Based on Exposed release 1.11.0
Suspending transaction, schema/table lifecycle, R2DBC driver, assertion, and Testcontainers fixtures.
Problem
Section titled “Problem”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.
When to use it
Section titled “When to use it”Use it for R2DBC repository, query, driver, cancellation, and framework integration tests. It is a test dependency, not an application runtime module.
Coordinates
Section titled “Coordinates”testImplementation("io.github.bluetape4k.exposed:bluetape4k-exposed-r2dbc-tests"), managed by the central BOM.
Core concepts
Section titled “Core concepts”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.
Quick start
Section titled “Quick start”withTables(TestDB.POSTGRESQL, Actors) { Actors.insert { it[name] = "Ada" } Actors.selectAll().count() shouldBeEqualTo 1L}API by task
Section titled “API by task”| Task | API |
|---|---|
| Suspending transaction fixture | withDb |
| Table/schema lifecycle | withTables, withSchemas |
| Auto-commit probe | withAutoCommit |
| R2DBC database matrix | TestDB, configs and container helpers |
| Shared assertions/schema | assertion and shared packages |
Recommended patterns
Section titled “Recommended patterns”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.
Integrations
Section titled “Integrations”The module exposes R2DBC SPI/pool, H2/MariaDB/MySQL/PostgreSQL R2DBC drivers, JUnit 5, and Testcontainers support for tests.
Configuration
Section titled “Configuration”Choose TestDB, driver options, and optional DatabaseConfig per fixture. Temporary database references are restored after execution.
Failure modes
Section titled “Failure modes”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.
Operations
Section titled “Operations”Capture driver/container logs, coroutine timeout, and pool state on failure. Bound every test so a driver cancellation defect cannot hang the suite indefinitely.
Testing
Section titled “Testing”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.
Workshops and learning path
Section titled “Workshops and learning path”Apply it after Coroutine transactions, then follow Cancellation and testing.
Limitations
Section titled “Limitations”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.
Release diagrams
Section titled “Release diagrams”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
Section titled “Test Infrastructure Structure diagram”Release README: exposed/r2dbc-tests/README.md
withTables R2DBC test lifecycle diagram
Section titled “withTables R2DBC test lifecycle diagram”Release README: exposed/r2dbc-tests/README.md

